Runtime Xcode and REPL Error.

162 views
Skip to first unread message

Bart C

unread,
Oct 31, 2019, 1:45:15 AM10/31/19
to Swift for TensorFlow
Using:
- XCODE: Version 11.1 (11A1027)
- TOOLCHAIN: Swift for TensorFlow 0.5 Release
- OS: macOS Mojave 10.14.6 (18G103)

I created an Xcode command line project with Legacy Build System, and have the following:

import TensorFlow

let a: Tensor<Float> = [1,2,3]


But at runtime, I get the error:

dyld: Library not loaded: @rpath/libswiftTensorFlow.dylib

  Referenced from: /Users/bart/Library/Developer/Xcode/DerivedData/s4tf-demo-2-bzqergeougqywyfzxfvwvacyvncd/Build/Products/Debug/s4tf-demo-2

  Reason: no suitable image found.  Did find:

/Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.5.xctoolchain/usr/lib/swift/macosx/libswiftTensorFlow.dylib: code signature in (/Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.5.xctoolchain/usr/lib/swift/macosx/libswiftTensorFlow.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)


I get a similar error for the Python module as well:

import Python

print(Python.version)


dyld: Library not loaded: @rpath/libswiftPython.dylib

  Referenced from: /Users/bart/Library/Developer/Xcode/DerivedData/s4tf-demo-2-bzqergeougqywyfzxfvwvacyvncd/Build/Products/Debug/s4tf-demo-2

  Reason: no suitable image found.  Did find:

/Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.5.xctoolchain/usr/lib/swift/macosx/libswiftPython.dylib: code signature in (/Library/Developer/Toolchains/swift-tensorflow-RELEASE-0.5.xctoolchain/usr/lib/swift/macosx/libswiftPython.dylib) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)


If I compile and run either as a file from the command line, it works fine as expected. But if I use the REPL:

Welcome to Swift version 5.1-dev (LLVM 200186e28b, Swift 1238976565).
Type :help for assistance.
  1> import TensorFlow
  2> let a: Tensor<Float> = [1,2,3]
a: Tensor<Float> =0  lldb                     0x00000001066ee9f5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  lldb                     0x00000001066edfd7 llvm::sys::RunSignalHandlers() + 39
2  lldb                     0x00000001066ef048 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff658c6b5d _sigtramp + 29
4  libsystem_platform.dylib 0x00007f810a7fc080 _sigtramp + 2767410496
5  LLDB                     0x0000000106dd1b23 lldb_private::formatters::swift::ObjectDescription_SummaryProvider(lldb_private::ValueObject&, lldb_private::Stream&, lldb_private::TypeSummaryOptions const&) + 51
6  LLDB                     0x0000000106a824b5 lldb_private::CXXFunctionSummaryFormat::FormatObject(lldb_private::ValueObject*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, lldb_private::TypeSummaryOptions const&) + 101
7  LLDB                     0x0000000106a56b8a lldb_private::ValueObject::GetSummaryAsCString(lldb_private::TypeSummaryImpl*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, lldb_private::TypeSummaryOptions const&) + 218
8  LLDB                     0x0000000106a56aa0 lldb_private::ValueObject::GetSummaryAsCString(lldb_private::TypeSummaryImpl*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, lldb::LanguageType) + 64
9  LLDB                     0x0000000106a85184 lldb_private::ValueObjectPrinter::PrintValueAndSummaryIfNeeded(bool&, bool&) + 276
10 LLDB                     0x0000000106a8465c lldb_private::ValueObjectPrinter::PrintValueObject() + 348
11 LLDB                     0x0000000106a5cfab lldb_private::ValueObject::Dump(lldb_private::Stream&, lldb_private::DumpValueObjectOptions const&) + 107
12 LLDB                     0x0000000106d287ac lldb_private::SwiftREPL::PrintOneVariable(lldb_private::Debugger&, std::__1::shared_ptr<lldb_private::StreamFile>&, lldb_private::SharingPtr<lldb_private::ValueObject>&, lldb_private::ExpressionVariable*) + 1180
13 LLDB                     0x0000000106aa9e69 lldb_private::REPL::IOHandlerInputComplete(lldb_private::IOHandler&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 3113
14 LLDB                     0x0000000106a1c750 lldb_private::IOHandlerEditline::Run() + 368
15 LLDB                     0x0000000106a02c1b lldb_private::Debugger::ExecuteIOHandlers() + 123
16 LLDB                     0x0000000106a05813 lldb_private::Debugger::IOHandlerThread(void*) + 19
17 LLDB                     0x0000000106ab2667 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) + 103
18 libsystem_pthread.dylib  0x00007fff658cf2eb _pthread_body + 126
19 libsystem_pthread.dylib  0x00007fff658d2249 _pthread_start + 66
20 libsystem_pthread.dylib  0x00007fff658ce40d thread_start + 13
[1]    18440 segmentation fault  swift


Dan Zheng

unread,
Nov 1, 2019, 1:36:00 AM11/1/19
to Bart C, Swift for TensorFlow
Hi Bart,

Sorry for the late reply! We discussed a bit offline, sharing our findings here.

I created an Xcode command line project with Legacy Build System, and have the following:
import TensorFlow
let a: Tensor<Float> = [1,2,3]
But at runtime, I get the error:
dyld: Library not loaded: @rpath/libswiftTensorFlow.dylib

This error occurs when creating Xcode projects via Xcode (Xcode > File > New > Project > ...) instead of SwiftPM.
In general, SwiftPM works better with Swift for TensorFlow toolchains:

mkdir Foo
cd Foo
swift package init --type executable
# Edit sources to import and use TensorFlow.
swift test

If I compile and run either as a file from the command line, it works fine as expected. But if I use the REPL:

Thanks for reporting the Tensor REPL printing issue for the S4TF 0.5 macOS toolchain - I filed TF-940 to track it.
Investigation may be blocked by TF-934. I verified that the printing issues don't occur with the 0.4 macOS toolchain.
We should add lldb tests to prevent such regressions.

Dan

--
To unsubscribe from this group and stop receiving emails from it, send an email to swift+un...@tensorflow.org.
Reply all
Reply to author
Forward
0 new messages