Installing Caffe For Windows Python

Active3 months ago
For

Apr 05, 2017  If you want to install Caffe on Ubuntu 16.04 along with Anaconda (Python 3.6 version), here is an installation guide: Install Nvidia driver and Cuda (Optional) If you want to use GPU to accelerate, follow instructions here to install Nvidia drivers, CUDA 8RC and cuDNN 5 (skip caffe installation there). Install Anaconda. Download Anaconda from here.

I'm trying to use Caffe in Anaconda3 on windows, but when I try to import caffe in iPython, it shows this error:

ImportError: No module named caffe

I tried to add a new system variable named PYTHONPATH which looks like this:

It still shows the same error. I would appreciate if anyone mentioned what am I missing here?

Installing Caffe For Windows PythonHadi GhahremanNezhadHadi GhahremanNezhad
9261 gold badge9 silver badges22 bronze badges
Installing Caffe For Windows Python

1 Answer

REM Create a new conda environment to install CaffeREM You can use python 3.5, 3.6 or 3.7

REM activate the environmentREM Depending on your conda version you may have to use activate caffe

REM add the anaconda channel to resolve all dependencies

REM Install caffe with cuda support or install caffe-cpu if you do not want CUDA support

Answer taken from here: https://github.com/BVLC/caffe/issues/6569#issuecomment-432491851

minar09minar09

Not the answer you're looking for? Browse other questions tagged pythonimportcaffe or ask your own question.

Caffe is a deep learning framework made with expression, speed, and modularity in mind.It is developed by Berkeley AI Research (BAIR)/The Berkeley Vision and Learning Center (BVLC) and community contributors.

Check out the project site for all the details like

  • BAIR reference models and the community model zoo

and step-by-step examples.

Windows Setup

Requirements: Visual Studio 2015, CUDA 9.0, third party libraries: Baidu Yun or Google Drive. Please extract the archive into ./windows/thirdparty/. Then, add the folder ./windows/thirdparty/bins to the environment variable PATH.

Pre-Build Steps

Copy .windowsCommonSettings.props.example to .windowsCommonSettings.props

By defaults Windows build requires CUDA and cuDNN libraries.Both can be disabled by adjusting build variables in .windowsCommonSettings.props.Python support is disabled by default, but can be enabled via .windowsCommonSettings.props as well.

CUDA

Download CUDA Toolkit 8.0from nVidia website.If you don't have CUDA installed, you can experiment with CPU_ONLY build.In .windowsCommonSettings.props set CpuOnlyBuild to true and set UseCuDNN & UseNCCL to false.

Caffe Python Install

cuDNN

Download cuDNN v5from nVidia website.Unpack downloaded zip to %CUDA_PATH% (environment variable set by CUDA installer).Alternatively, you can unpack zip to any location and set CuDnnPath to point to this location in .windowsCommonSettings.props.CuDnnPath defined in .windowsCommonSettings.props.Also, you can disable cuDNN by setting UseCuDNN to false in the property file.

Python

To build Caffe Python wrapper set PythonSupport to true in .windowsCommonSettings.props.Download Miniconda 2.7 64-bit Windows installer [from Miniconda website] (http://conda.pydata.org/miniconda.html).Install for all users and add Python to PATH (through installer).

Run the following commands from elevated command prompt:

Remark

After you have built solution with Python support, in order to use it you have to either:

  • set PythonPath environment variable to point to <caffe_root>Buildx64Releasepycaffe, or
  • copy folder <caffe_root>Buildx64Releasepycaffecaffe under <python_root>libsite-packages.

Matlab

To build Caffe Matlab wrapper set MatlabSupport to true and MatlabDir to the root of your Matlab installation in .windowsCommonSettings.props.

Remark

Anaconda Caffe Install Windows 10

After you have built solution with Matlab support, in order to use it you have to add the ./matlab folder to Matlab search path.

Build

Installing Caffe For Windows Python Server

Now, you should be able to build .windowsCaffe.sln

Installing Python For Windows 10

License and Citation

Caffe is released under the BSD 2-Clause license.The BAIR/BVLC reference models are released for unrestricted use.

Please cite Caffe in your publications if it helps your research: