BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
34.1k stars 18.7k forks source link

Caffe on Windows #15

Closed bearpaw closed 7 years ago

bearpaw commented 10 years ago

I have successfully run Caffe on Ubuntu 12.04. I am wondering whether Caffe is able to run on Windows system?

shelhamer commented 10 years ago

In principle compiling and running on Windows is possible, but we do not have a Makefile for it, nor do we currently plan on supporting it. However, contributions to this end are welcome!

niuzhiheng commented 10 years ago

I have ported Caffe to Windows. It is built by Visual Studio 2012.

shelhamer commented 10 years ago

Thank you for porting Caffe! Could you publish your code on your fork? We do not officially support windows yet, but we could direct others interested in running Caffe on windows to your work.

niuzhiheng commented 10 years ago

Yes, I created a new branch named as "windows" on my own repository.

You may refer to the installation guide for more details.

Look forward to any feedback from all of you.

nian-liu commented 10 years ago

@niuzhiheng Can your windows version codes run in a VS2010 environment?

niuzhiheng commented 10 years ago

I am not sure for VS2010, but it has been confirmed that both VS2012 professional and VS2012 express are OK. There are two main concerns for other Visual Studio versions: 1) whether std::thread is working fine with other versions earlier than VS2012. 2) 3rd-party libraries may need to be rebuilt correspondingly, e.g. OpenCV.

nian-liu commented 10 years ago

@niuzhiheng I am wondering could I have your mail ID - I have some questions in building caffe by vs 2010 and would like to get some directions from you. My gmail is liunian228@gmail.com, thanks in advance!

zgxiangyang commented 10 years ago

@niuzhiheng I have downloaded your fork, but i can only find the ".dll" files, no ".h" files and "*.lib" files of "3rdparty." it is not easy to build these "x64" libraries in windows, can you share it in the project too? thanks!

niuzhiheng commented 10 years ago

@zgxiangyang The dependencies can be download from here

You may refer to the installation guide for more details.

zgxiangyang commented 10 years ago

@niuzhiheng I have downloaded it before, there are only several".dll" files. But without the corresponding '.lib" files, I have no way to use it in my projects. I can only run the demo. It's too hard for me to build my own libs.

aybassiouny commented 10 years ago

Thanks a lot @niuzhiheng, your windows port works handsomely on windows server 2012 with VS2012.

One note for others using the windows branch that took me sometime to figure, they should use the old architecture (the one with explicit padding layers) not the new one. i.e. in order to use the cifar sample, they should use this net architecture, not the one in master. Mnist example in master works smoothly as it does not have any padding layers.

niuzhiheng commented 10 years ago

@aybassiouny you are correct. I am considering to update the windows port to new net architecture and up to date when caffe officially release 1.0 version.

aybassiouny commented 10 years ago

@niuzhiheng new PR is out!

thuanvh commented 10 years ago

Hi, I am planning to compile caffe in win32. It seems the dependencies building is difficult. @niuzhiheng Could you help to build win32 dependencies files and share it.

bhack commented 10 years ago

Cmake can generate Visual Studio files. Take a look at https://github.com/BVLC/caffe/pull/442 Instead Mxe[¹] and Cmake could be a good base for compile with mingw for windows target on linux [1]http://mxe.cc/

kloudkl commented 10 years ago

Not all the dependencies are compatible with Windows. For example, the pthread used by the various data layer to prefetch the data is only available on Linux/Unix. If they are not replaced by boost::thread, you can only simulate Linux with MinGW or Cygwin. In my experiences, they brought up too many unnecessary complications and are not suitable for running complex projects such as Caffe and it's dependencies.

If you do want to use Caffe, install the latest version of Ubuntu which is the most popular and the easiest Linux OS.

niuzhiheng commented 10 years ago

@kloudkl is right. The official Linux version is well supported by the Caffe community with frequent updates and discussions. The windows porting currently has many limitations and most importantly it is lacking community support.

One may start with this windows porting, if you quite rely on visual studio as your favorite IDE. Once you become familiar with Caffe, you'd better deploy from the official branches.

aybassiouny commented 10 years ago

I have managed to compile latest caffe using #442, it is kind of a hellish process, but overall I fixed major errors following footsteps of @niuzhiheng's port.

I am a total newbie to github, should I submit it as a pull request to to the windows port?

thuanvh commented 10 years ago

I am interested in caffe for windows. Could you push your changes to github? Could you create a branch and push it up? @aybassiouny

-----Thư Gốc----- Từ: "aybassiouny" notifications@github.com Gửi: ‎29/‎06/‎2014 6:13 SA Đến: "BVLC/caffe" caffe@noreply.github.com Cc: "thuanvh" thuanvh@gmail.com Chủ đề: Re: [caffe] Caffe on Windows (#15)

I have managed to compile latest caffe using #442, it is kind of a hellish process, but overall I fixed major errors following footsteps of @niuzhiheng's port. I am a total newbie to github, should I submit it as a pull request to to the windows port? — Reply to this email directly or view it on GitHub.

shelhamer commented 10 years ago

@aybassiouny my advice is to coordinate with @niuzhiheng, who has kindly kept the Windows port at his fork, to make you a collaborator on his repo or otherwise submit a PR there.

A good first step is to push your Windows branch to your own fork and link it in this thread for others to find.

On Sun, Jun 29, 2014 at 3:47 AM, thuanvh notifications@github.com wrote:

I am interested in caffe for windows. Could you push your changes to github? Could you create a branch and push it up? @aybassiouny

-----Thư Gốc----- Từ: "aybassiouny" notifications@github.com Gửi: ‎29/‎06/‎2014 6:13 SA Đến: "BVLC/caffe" caffe@noreply.github.com Cc: "thuanvh" thuanvh@gmail.com Chủ đề: Re: [caffe] Caffe on Windows (#15)

I have managed to compile latest caffe using #442, it is kind of a hellish process, but overall I fixed major errors following footsteps of @niuzhiheng's port. I am a total newbie to github, should I submit it as a pull request to to the windows port? — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/BVLC/caffe/issues/15#issuecomment-47451170.

rbgirshick commented 10 years ago

You might also want to check with @s-gupta who has experience compiling and using caffe on Windows as part of an internship.

wusx11 commented 10 years ago

@niuzhiheng Excuse me, I'm trying to run your code on windows platform. But it seems the download link of the dependencies you gave are not available now...I'm not sure whether it's the problem of my network. Could you please check the download link? Thanks a lot!!!

thuanvh commented 10 years ago

I have no problem in downloading dependencies of windows. https://dl.dropboxusercontent.com/u/3466743/caffe-vs2012/dependency.7z

wusx11 commented 10 years ago

@thuanvh Well, maybe there's something wrong with my network... I've already got the dependencies through other ways. Thanks!!

niuzhiheng commented 10 years ago

Please use the updated download link if you use my updated code. Up to now, I have three versions, dependency.7z, dependency-20140514.7z, dependency-20140624.7z. You may be able to see the correct one to use from the readme.md file in the code you are using.

niuzhiheng commented 10 years ago

@aybassiouny and @shelhamer I am also interested in using CMake for windows porting. And I am very glad to have @aybassiouny as a collaborator to my repo if you want.

shelhamer commented 10 years ago

@niuzhiheng @aybassiouny that sounds like a productive collaboration. Go for it!

kloudkl commented 10 years ago

@shelhamer, #573 works on Ubuntu, Debian and Mint. It is mature enough to be merged.

shelhamer commented 10 years ago

@kloudkl Please discuss at #573. This thread is not about Cmake.

aybassiouny commented 10 years ago

Here's the repo for cmake-produced caffe: https://github.com/aybassiouny/wincaffe-cmake. @niuzhiheng could you give it a try?

niuzhiheng commented 10 years ago

@aybassiouny Great! I'd love to try.

niuzhiheng commented 10 years ago

@aybassiouny Sorry I am still having some problems to successfully build your wincaffe-cmake. One thing I am glad to share and notify you is that @OpenHero submitted a new PR #643. Please take a look if you are interested in making cmake version for that code. I think we need to work together for a better windows porting. @shelhamer your comments and suggestions are very welcome.

OpenHero commented 10 years ago

Hi All, I had update the PR #643. @niuzhiheng hi, I add you into my caffe fork. https://github.com/OpenHero/caffe

On Wed, Jul 9, 2014 at 1:04 PM, NIU ZHIHENG notifications@github.com wrote:

@aybassiouny https://github.com/aybassiouny Sorry I am still having some problems to successfully build your wincaffe-cmake. One thing I am glad to share and notify you is that @OpenHero https://github.com/OpenHero submitted a new PR #643 https://github.com/BVLC/caffe/pull/643. Please take a look if you are interested in making cmake version for that code. I think we need to work together for a better windows porting. @shelhamer https://github.com/shelhamer your comments and suggestions are very welcome.

— Reply to this email directly or view it on GitHub https://github.com/BVLC/caffe/issues/15#issuecomment-48430392.

Best wishes, Kaiyong Zhao

jashaikh commented 10 years ago

Hi All,

I am new to Caffe and I have worked always in Windows. I followed the installation steps of the Caffe for Windows: https://github.com/niuzhiheng/caffe/blob/windows/README.md

But when I tried to build MainBuilder.sln using default train_net.cpp, I get the following errors:


1>------ Build started: Project: MainCaller, Configuration: Debug x64 ------ 1> caffe.pb.h is being generated 1> '"./tools/protoc"' is not recognized as an internal or external command, 1> operable program or batch file. 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: The command "set origin_dir=Í% 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: cd ../../ 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: "./scripts/GeneratePB.bat" 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: cd %origin_dir% 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: :VCEnd" exited with code 1. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Would you please help me sort out the problem?

OpenHero commented 10 years ago

Need "protoc.exe" Google protocbuffer tool.

Sent from my iPhone

On 21 Jul, 2014, at 0:11, jashaikh notifications@github.com wrote:

Hi All,

I am new to Caffe and I have worked always in Windows. I followed the installation steps of the Caffe for Windows: https://github.com/niuzhiheng/caffe/blob/windows/README.md

But when I tried to build MainBuilder.sln using default train_net.cpp, I get the following errors:

1>------ Build started: Project: MainCaller, Configuration: Debug x64 ------ 1> caffe.pb.h is being generated 1> '"./tools/protoc"' is not recognized as an internal or external command, 1> operable program or batch file. 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: The command "set origin_dir=Í% 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: cd ../../ 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: "./scripts/GeneratePB.bat" 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: cd %origin_dir% 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(124,5): error MSB3073: :VCEnd" exited with code 1. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Would you please help me sort out the problem?

— Reply to this email directly or view it on GitHub.

jashaikh commented 10 years ago

Thanks a lot for the help.

But "proto.exe" is present at this path: F:\Javed\VC\VC2012\cnn_train\caffe-windows\build\MSVC\tools

And the "MainBuilder.sln" is present at the path: F:\Javed\VC\VC2012\cnn_train\caffe-windows\build\MSVC

Furthermore, the compiler has underlined the words "google", "LOG", "ERROR", "INFO", "SolverParameter" with red color in "train_net.cpp" file.

Moreover, can you please explain what is the meaning of "../../" in the following line in MainCaller.cpp:

include "../../tools/train_net.cpp"

OpenHero commented 10 years ago

@jashaikh https://github.com/OpenHero/caffe/wiki/Caffe-setup-in-Windows-system FYI.

jashaikh commented 10 years ago

@OpenHero The installation steps of your Caffe version needs to access D: partition of HDD. (Furthermore, we will have to download all the dependencies ourselves.) What if someone has (or wants to use) C: partition? That's why I am still trying to compile niuzhiheng's version, which now requires caffe/proto/caffe.pb.h, but this file is not located anywhere in his or your package. Thanks

niuzhiheng commented 10 years ago

caffe.pb.h can be generated by protoc.exe when you compile the project for the first time.

jashaikh commented 10 years ago

@niuzhiheng Do I have to supply some arguments or I will have to just run protoc.exe as it is in the DOS command window before I compile the MainBuilder.sln? Thanks

jashaikh commented 10 years ago

@niuzhiheng I have created the caffe.pb.h file following OpenHero's installation instructions. Finally, I built the project, though with many warnings (but not errors). It created the MainCaller.exe in the bin folder. Then, I double clicked the train_lenet.bat to start training on the MNIST dataset, but it displayed the following error message in the Command Prompt window: "The program can't start because libgfortran-3.dll is missing from your computer. Try reinstalling the program to fix this problem." Would you please help me sort out the problem?

niuzhiheng commented 10 years ago

You may find it here.

jashaikh commented 10 years ago

@niuzhiheng Thanks for the updated dependency files. It resolved the previous issue, but now the following run-time error has occured, even when I had double clicked the "get_mnist_leveldb.bat" file in the Windows Explorer before running the "train_lenet.bat" file.

I0803 12:07:31.110451  6872 data_layer.cpp:145] Opening leveldb mnist-train-leve
ldb
F0803 12:07:31.131301  6872 data_layer.cpp:148] Check failed: status.ok() Failed
 to open leveldb mnist-train-leveldb
Invalid argument: mnist-train-leveldb: does not exist (create_if_missing is fals
e)
*** Check failure stack trace: ***

Would you please help in this regard?

niuzhiheng commented 10 years ago

@jashaikh you may refer to this thread.

By the way, you may change the

=======  to   ` ` ` (no space)

so that your code printed can be normal.

jashaikh commented 10 years ago

@niuzhiheng I saw that thread, but he was using his own dataset, and it seems you were suggesting him to use the same dataset as trainset and testset by just renaming the database! On the contrary, I intend to use MNIST dataset just to get acquainted with Caffe, but I am not sure what exactly the get_mnist_leveldb.bat does. If it downloads the MNIST dataset from some webpage according to the instructions inside the .bat file, where does it put the dataset (since I can't locate the downloaded file anywhere) and whether I have to do anything manually with that downloaded file or not. For example, do I need to copy and rename the trainset as testset as you suggested him? Thanks for your support.

niuzhiheng commented 10 years ago

@jashaikh The downloading script has been updated. It seems dropbox has deprecated the http way. It can only be downloaded by wget with https support. You may download the new dependency which support https and update the get_mnist_leveldb. Once again, can you please update your last second post by wrapping around the ==== your output ==== by "```" ? Thank you.

shelhamer commented 10 years ago

Note that we migrated from Dropbox to our own download site for bandwidth concerns. See any of the latest download scripts. Thanks for maintaining your Windows port!

On Sunday, August 3, 2014, NIU ZHIHENG notifications@github.com wrote:

@jashaikh https://github.com/jashaikh The downloading script has been updated https://github.com/niuzhiheng/caffe/commit/efbfdae0ceabf4e01b07d69e8194db74e3302d04. It seems dropbox has deprecated the http way. It can only be downloaded by wget with https support. You may download the new dependency which support https and update the get_mnist_leveldb https://github.com/niuzhiheng/caffe/blob/efbfdae0ceabf4e01b07d69e8194db74e3302d04/examples/mnist/get_mnist_leveldb.bat .

— Reply to this email directly or view it on GitHub https://github.com/BVLC/caffe/issues/15#issuecomment-51013339.

jashaikh commented 10 years ago

@niuzhiheng I downloaded the new dependency files and replaced the old ones with them. Then I ran get_mnist_leveldb.bat. It did something, but I still don't know where it put the MNIST database if it downloaded it. Then, I ran the train_lenet.bat, it again produced the following output:

I0805 22:52:02.520145  9128 train_net.cpp:26] Starting Optimization
I0805 22:52:02.523147  9128 solver.cpp:41] Creating training net.
I0805 22:52:02.529149  9128 net.cpp:64] Memory required for Data0
I0805 22:52:02.529149  9128 net.cpp:75] Creating Layer mnist
I0805 22:52:02.530151  9128 net.cpp:111] mnist -> data
I0805 22:52:02.531152  9128 net.cpp:111] mnist -> label
I0805 22:52:02.531152  9128 data_layer.cpp:145] Opening leveldb mnist-train-leve
ldb
F0805 22:52:02.536154  9128 data_layer.cpp:148] Check failed: status.ok() Failed
 to open leveldb mnist-train-leveldb
Invalid argument: mnist-train-leveldb: does not exist (create_if_missing is fals
e)
*** Check failure stack trace: ***

BTW, the web link in get_mnist_leveldb.bat file is still http. Shouldn't it be https as you mentioned?

Thanks

bhack commented 10 years ago

Cmake branch was merged in dev now.

niuzhiheng commented 10 years ago

The slow speed issue has been solved since the upgrade of GPU driver to 340.62 and CUDA toolkit to 6.5. Now the windows version can run as fast as linux version.