0
votes

I'm trying to run a Jupyter notebook that uses Caffe. Caffe is not included in datalab. I am trying to install that library from within the Jupyter notebook (as recommended in the datalab docs), but am running into problems.

I am new to datalab, and a novice with such things generally. Any advice would be very much appreciated.

The datalab documentation suggests 3 strategies for adding a python library that is not already included. I am concentrating on the first two of these strategies.

The platform for my datacloud instance is:

platform.platform() 'Linux-4.4.111+-x86_64-with-debian-stretch-sid'

Below I'll list various things I've tried and the error messages I got. For the first strategy, I tried these things in a cell of the same notebook.

(Attempt 1)

!pip install caffe
#results in the error:
#Collecting caffe
#  Could not find a version that satisfies the requirement caffe (from 
#versions: )
#No matching distribution found for caffe

!pip install caffe-cpu
#results in the same error as above

I realized from my research that caffe could not be installed with pip, so I tried:

(Attempt 2)

!apt-get install caffe
#results in the error:
#Reading package lists... Done
#Building dependency tree       
#Reading state information... Done
#E: Unable to locate package caffe

!apt-get install caffe-cpu
#results in the same error as above

Based on another stackoverflow question, I tried the following for both caffe and caffe-cpu:

(Attempt 3)

%bash
echo 'Y' | apt-get update
echo 'Y' | apt-get install caffe-cpu
#This results in output with a lot of warnings, but ends with the error:
#E: Unable to locate package caffe-cpu
#Stack Overflow prevented me from posting the entire thing, thinking it was spam

(Attempt 4)

Based on the second strategy recommended in the documentation, I tried running this code in a separate notebook:

%%bash
echo "pip install caffe" >> /content/datalab/.config/startup.sh
cat /content/datalab/.config/startup.sh
#This resulted in the error:
#bash: /usr/local/lib/libtinfo.so.5: no version information available (required by bash)

I got the same results when I ran:

%%bash
echo "apt-get install caffe" >> /content/datalab/.config/startup.sh
cat /content/datalab/.config/startup.sh
1

1 Answers

0
votes

I tried on my end to install caffe-cpu, and it seems that the file /etc/apt/sources.list doesn't have the needed repositories to install it, in the datalab instance. To workaround this issue, I used the following commands, in a created notebook:

!echo "deb http://deb.debian.org/debian stretch main\n\
deb-src http://deb.debian.org/debian stretch main\n\
deb http://deb.debian.org/debian-security/ stretch/updates main\n\
deb-src http://deb.debian.org/debian-security/ stretch/updates main\n\
deb http://deb.debian.org/debian stretch-updates main\n\
deb-src http://deb.debian.org/debian stretch-updates main" >> /etc/apt/sources.list

This will add the necessary debian/stretch repositories that include the caffe-cpu package.

Note: Strangely I didn't need to add the -e flag to the echo command in order to correctly read the newlines, you can check if the file has been correctly updated by doing !cat /etc/apt/sources.list.

Once that is done, run the following command:

!apt-get update && apt-get install caffe-cpu -y --allow-unauthenticated

Once the command finishes, the caffe-cpu package will be installed in your VM.