google / swift-jupyter

Apache License 2.0
618 stars 90 forks source link

Docker image fails to run Swift code #115

Closed goccmack closed 3 years ago

goccmack commented 3 years ago

I installed a Docker image as per Option 3 in https://github.com/google/swift-jupyter/blob/master/README.md on a Mac with OSX version 10.15.7 and Docker desktop version 2.4.0.0.

I created a new notebook with a Swift kernel and tried to run the single code cell:

print("hello")

which produces the following error:

Cannot create Swift scratch context (couldn't load the Swift stdlib)Cannot create Swift scratch context (couldn't load the Swift stdlib)[IPKernelApp] ERROR | Exception in message handler: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell yield gen.maybe_future(handler(stream, idents, msg)) File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 735, in run value = future.result() File "/usr/local/lib/python3.6/dist-packages/tornado/gen.py", line 209, in wrapper yielded = next(result) File "/usr/local/lib/python3.6/dist-packages/ipykernel/kernelbase.py", line 545, in execute_request user_expressions, allow_stdin, File "/swift-jupyter/swift_kernel.py", line 967, in do_execute self._init_swift() File "/swift-jupyter/swift_kernel.py", line 217, in _init_swift self._init_int_bitwidth() File "/swift-jupyter/swift_kernel.py", line 303, in _init_int_bitwidth result) Exception: Expected value from Int.bitWidth, but got: SuccessWithoutValue()

The notebook exists on disk and produces the same error every time I load it and attempt to run the cell above.

goccmack commented 3 years ago

I solved the problem by making the following change to the Dockerfile:

Allow the caller to specify the toolchain to use

ARG swift_tf_url=https://storage.googleapis.com/swift-tensorflow-artifacts/nightlies/latest/swift-tensorflow-DEVELOPMENT-cuda10.2-cudnn7-ubuntu18.04.tar.gz

changed to:

ARG swift_tf_url=https://storage.googleapis.com/swift-tensorflow-artifacts/releases/v0.11/rc2/swift-tensorflow-RELEASE-0.11-ubuntu18.04.tar.gz

marcrasi commented 3 years ago

Hmm, it should work even without the change. I'll take a look. Thanks for reporting this!

Do you have the latest master commit of swift-jupyter? I remember recently fixing an error that looks a lot like this, so maybe you just have a slightly older version.

goccmack commented 3 years ago

@marcrasi Yes. I cloned master this morning.

Thanks for this wonderful tool.

Hmm, it should work even without the change. I'll take a look. Thanks for reporting this!

Do you have the latest master commit of swift-jupyter? I remember recently fixing an error that looks a lot like this, so maybe you just have a slightly older version.

marcrasi commented 3 years ago

Oh I figured it out. The latest toolchains require --privileged instead of --cap-add SYS_PTRACE. I have updated the README, and I have also filed https://github.com/google/swift-jupyter/issues/116 because I would like to have it working without needing --privileged.