S4TF in colab (error)


I went to the Swift github repo, clicked on Usage.md, and clicked on “Open this Swift installation notebook” (https://colab.research.google.com/github/tensorflow/swift/blob/master/notebooks/install_latest_swift.ipynb).

Installation was fine and I got the appropriate output --> using the latest version of Swift. Went back to the same github page and opened the link again and checked that Swift was running fine in the new colab notebook

I used File -> upload to load “00_load_data.ipynb” from the fastai “dev_swift” folder. Checked that runtime type was “Swift” and hardware accelerator was “GPU”.

Running the first cell generated the error:

Kernel is in a bad state. Try restarting the kernel.

Exception in `_process_installs`:

[Errno 17] File exists: '/content/swift-install' -> '/tmp/tmpcapibpcx/swift-install'

I tried running the next notebook "00a_intro_and_float.ipynb"and received the following error running the first cell:

error: <Cell 1>:1:18: error: consecutive statements on a line must be separated by ';'
%install-location $cwd/swift-install

I didn’t expect the second notebook to run properly since I hadn’t been able to get the load_data notebook to run, but I thought it was an interesting error in the first cell. What are the “consecutive statements” that Swift finds in the first line?

%install-location $cwd/swift-install

Jeremy's Harebrained install guide
(Dan Zheng (Swift for TensorFlow)) #2

Good question!

Swift for TensorFlow v0.3 hasn’t propagated to Colab yet (the process takes a few business days). We expect v0.3 to be available in Colab on Tuesday morning. Until then, new features like %install directives won’t work.

In the meantime, please install swift-jupyter locally (Jeremy’s install guide, instructions from swift-jupyter README). Sorry for the inconvenience!


How to use/install a Swift library in Collab
(Dan Zheng (Swift for TensorFlow)) #3

Note: Colab supports loading any notebook from GitHub, so you don’t need to manually upload notebooks.

Example link: https://colab.sandbox.google.com/github/fastai/fastai_docs/blob/master/dev_swift/00_load_data.ipynb

Not sure if it’ll work out-of-the-box will %install directives though. @marcrasi (swift-jupyter lead) might have some idea.


(Marc Rasi (S4TF Team)) #4

Seems like the %install-location does not work on Colab. It’s not important for the functioning of the notebook (it just makes it start up a bit faster), so you can fix this problem by deleting the %install-location line. I’ll investigate and fix this eventually.

This is an error that you would get from running an older version of swift-jupyter that doesn’t have %install. You probably accidentally switched to a different VM from the VM you ran the install notebook on. (There are a lot ways this can happen: using a different accelerator type, not unchecking the “reset all runtimes” box in the “warning this is not authored by google” dialog).

There is one additional problem that you will run into after you get around those problems. The fastai notebooks expect to read some dependencies from a copy of the fastai repo on the local filesystem. So you will need to download the fastai repo onto the VM’s local filesystem and move the dependencies into the right place. To do this, execute this code in a python colab:

!git clone https://github.com/fastai/fastai_docs.git
!mv fastai_docs/dev_swift/* /content

How to use/install a Swift library in Collab
(benedikt herudek) #5

+1 on this error, also after I tried not unchecking

So, will wait tuesday. But wondering, if there is a way in colab, where I can check this version ‘Swift for TensorFlow v0.3’ to verify this is the issue?

thanks for making this available on co-lab, saves the huzzle of setting up my own image! :wink:


(Marc Rasi (S4TF Team)) #6

You could run !/swift/toolchain/usr/bin/swift --version in a Colab python notebook, to get the commit hash of the currently-installed swift. Then you can look that up on https://github.com/apple/swift to see how recent it is. We haven’t been adding release version information into the toolchains, so it won’t tell you “v0.3” though. But it seems like there is a place for a version string that prints out next to the commit hash, and we should set it to our release version, so that it’s easy to tell what release you are on. I’ll keep this in mind for our next release!

1 Like

Implementing GeneralRelu in Swift
(benedikt herudek) #7

seems working now ! thx


(Korakot Chaovavanich) #8

You may want to update this to the new location:

!git clone https://github.com/fastai/course-v3.git
!mv course-v3/nbs/swift/* /content