happynear / caffe-windows

Configure Caffe in one hour for Windows users.
Other
1.32k stars 649 forks source link

How to use Python #283

Open mwindowshz opened 6 years ago

mwindowshz commented 6 years ago

Hi I have successfully build caffe-windows (VS2017 cuda 9.1 ) with python 3 (using 2015 toolset) image

Now I don't know how to use this in python project.

How do I import the python tried using

import caffe

and the result was

ModuleNotFoundError: No module named 'caffe'

tried a suggestion found in issues - ([https://github.com/happynear/caffe-windows/issues/225]#225)

import sys sys.path.append("/caffe-windows/python") import caffe

this also did not work received this error

import caffe

Traceback (most recent call last): File "", line 1, in File "C:\Users\xxxx\source\repos\caffe-windows-ms\caffe-windows-ms\python\caffe__init__.py", line 1, in from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer File "C:\Users\xxxx\source\repos\caffe-windows-ms\caffe-windows-ms\python\caffe\pycaffe.py", line 13, in from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \ ModuleNotFoundError: No module named 'caffe._caffe'

Also tried coping into anconda\lib\site-packges (as suggested by http://www.shaneahmed.com/2017/07/build-caffe-pycaffe-and-matcaffe-on.html) but got the same error.

I would be glad for guidance. Thanks in advance.

mwindowshz commented 6 years ago

Seems Like found the answer, 2 steps

  1. Add "..\caffe-windows-ms\Build\x64\Release" folder to windows PATH
  2. (using anaconda) copy ",,\caffe-windows-ms\Build\x64\Release\pycaffe\caffe" folder into "C:\ProgramData\Anaconda3\Lib\site-packages" (or wherever anaconda is installed on your computer)

Now import caffe works, still did not check actual code.