How to add caffe to anaconda on windows?

20,406

Solution 1

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

conda create -n caffe python=3.7

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

conda activate caffe

REM add the anaconda channel to resolve all dependencies

conda config --add channels anaconda

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

conda install caffe -c willyd

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

Solution 2

caffe doesn't have support for windows as it have for others. After trying many things, i am able to import caffe. The best solution i find is the git link https://github.com/Microsoft/caffe .

Create a virtual environment in Anaconda, python = 3.7 and then follow the instructions.

You would have to make changes CommonSettings.props as mentioned in the documentation for CUDA and cuDNN if you would be using it with CPU only.

clone repository to the location and copy caffe folder to .\anaconda3\envs\env_caffe\Lib\site-packages location as stated in the documentation .

and finally un the following commands from elevated command prompt:

conda install --yes numpy scipy matplotlib scikit-image pip pip install protobuf.

Read the instruction carefully and then proceed.

Share:
20,406
Hadi GhahremanNezhad
Author by

Hadi GhahremanNezhad

Updated on July 09, 2022

Comments

  • Hadi GhahremanNezhad
    Hadi GhahremanNezhad almost 2 years

    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:

    C:\Users\Hadi\Anaconda3;C:\Projects\caffe\python\caffe;C:\Projects\caffe\python
    

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

  • Tina J
    Tina J over 4 years
    conda install caffe -c willyd raises error: Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
  • minar09
    minar09 over 4 years
    Haven't tried this in a while. It used to work before. Maybe version incompatibility issue of anaconda or something.
  • LCMa
    LCMa about 3 years
    I tried it, and it worked for me. The incompatility had been solved.