1

after doing !apt install caffe-cuda i try to use caffe on google colaboratory but with no result. Any help will be welcomed. Thanks enter image description here

TheLetch
  • 375
  • 1
  • 4
  • 15

1 Answers1

0

The command apt install caffe-cuda installs cuda for Python3. For python2 you have to install it manually (cloning the git folder and make). Use the following commands in the colab notebook:

#Clone the repo
!cp caffe/Makefile.config.example caffe/Makefile.config

# Make changes to Makefile
!git clone https://github.com/BVLC/caffe.git
!sed -i 's/# OPENCV_VERSION/OPENCV_VERSION/g' caffe/Makefile.config
!sed -i 's/CUDA_ARCH :=/CUDA_ARCH :=\n/g' caffe/Makefile.config
!sed -i 's/# USE_CUDNN/USE_CUDNN/g' caffe/Makefile.config
!sed -i 's/# WITH_PYTHON_LAYER := 1/WITH_PYTHON_LAYER := 1\n/g' caffe/Makefile.config
!sed -i 's/-gencode arch=compute_20,code=sm_20/#-gencode arch=compute_20,code=sm_20/g' caffe/Makefile.config
!sed -i 's/-gencode arch=compute_20,code=sm_21/#-gencode arch=compute_20,code=sm_21/g' caffe/Makefile.config
!sed -i 's/\/usr\/local\/include/\/usr\/local\/include \/usr\/include\/hdf5\/serial/g' caffe/Makefile.config
!sed -i 's/\/usr\/local\/lib/\/usr\/local\/lib \/usr\/lib\/x86_64-linux-gnu\/hdf5\/serial/g' caffe/Makefile.config
!sed -i 's/\/usr\/lib\/python2.7\/dist-packages\/numpy/\/usr\/local\/lib\/python2.7\/dist-packages\/numpy/g' caffe/Makefile.config
!cat caffe/Makefile.config

#Install Dependencies
!sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev

#Make
!cd caffe && make -j32

Also, I was trying to install pycaffe. So once you make pycaffe, you have to add the python/ folder of caffe to sys. You can achieve it using:

import sys
sys.path.insert(1, "{path to pycaffe}/python")
  • Thanks for your reply,But how can you import caffe.io? I think the above steps may not be complete.hope to get your help,Thanks –  Nov 15 '19 at 15:04