New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Caffe2 building scripts #41
Conversation
Have to merge image_input_op.h to resolve conflict with the main branch. |
Ok, it runs after mege. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. These are the problems that need to be resolved before it can be merged. Anyway, I'll add it to the CI to test its feasibility.
msbuild /p:Configuration=Release /p:Platform=x64 /m:%NUM_BUILD_PROC% INSTALL.vcxproj /p:PreferredToolArchitecture=x64 | ||
) | ||
|
||
cd %ORIGINAL_DIR% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newline here
) | ||
|
||
rem Building Debug in %CAFFE2_ROOT%\build\Debug | ||
if %BUILD_DEBUG% EQU 1 ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a variable like CONFIG
and if "%CONFIG%"=="Debug"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this way, your code can be reused.
exit | ||
) | ||
|
||
if %CMAKE_LINKER% EQU "" ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to override the default linker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I explicitly specify x64 toolset to build caffe2_gpu.dll in Debug with pdbs.
exit | ||
) | ||
|
||
if %CMAKE_C_COMPILER% EQU "" ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use CC
and CXX
for unification.
) | ||
|
||
rem Now checking, that everything is defined for build... | ||
if %CMAKE_CXX_COMPILER% EQU "" ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use CC
and CXX
for unification.
|
||
rem msbuild /m: option value | ||
if NOT DEFINED NUM_BUILD_PROC ( | ||
set NUM_BUILD_PROC=6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use MAX_JOBS
for unification.
) | ||
|
||
rem Should build folder be deleted and build start from scratch? | ||
if NOT DEFINED CLEAR_BUILD_FOLDER_AND_START_AGAIN ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is so long, what about changing it into REBUILD
?
set CAFFE2_ROOT=%~dp0%\pytorch | ||
|
||
rem Cloning repository if it doesn't exist | ||
if not exist pytorch ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script internal\clone.bat
can be used here.
caffe2_builders/v140/auto.bat
Outdated
rem Building Debug in %CAFFE2_ROOT%\build\Debug | ||
if %BUILD_DEBUG% EQU 1 ( | ||
set CONFIG=Debug | ||
call msbuild.bat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%cd%
may not exactly equal to %~dp0
.
caffe2_builders/v140/auto.bat
Outdated
rem Building Release in %CAFFE2_ROOT%\build\Release | ||
if %BUILD_RELEASE% EQU 1 ( | ||
set CONFIG=Release | ||
call msbuild.bat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here.
exit | ||
) | ||
|
||
if %CMAKE_LINKER% EQU "" ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you changing the default linker? It's interesting,
caffe2_builders/v140/auto.bat
Outdated
|
||
rem msbuild /m: option value | ||
if NOT DEFINED MAX_JOBS ( | ||
set MAX_JOBS=6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using %NUMBER_OF_PROCESSORS%
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, it is rather number of processes, not devices.
https://www.hanselman.com/blog/FasterBuildsWithMSBuildUsingParallelBuildsAndMulticoreCPUs.aspx
Switch it to NUMBER_OF_PROCESSES?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%NUMBER_OF_PROCESSORS% stores the number of logical processors. For example, I have an i7-7700hq and then this env var is set to 8 by the OS. It's not good to pin the MAX_JOBS to a constant number.
caffe2_builders/v140/msbuild.bat
Outdated
exit | ||
) | ||
|
||
msbuild /p:Configuration=%CONFIG% /p:Platform=x64 /m:%MAX_JOBS% INSTALL.vcxproj /p:PreferredToolArchitecture=x64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newline here
caffe2_builders/v140/auto.bat
Outdated
|
||
if %REBUILD% EQU 1 ( | ||
if exist %CAFFE2_ROOT%\build ( | ||
rmdir %CAFFE2_ROOT%\build /s /q |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using python setup.py clean
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no setup.py here, everything is installed as CMake install rules specify.
Explain please, what do you want setup.py to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%CAFFE2_ROOT% is the path of the pytorch repo, then there should be setup.py under that directory. Run python setup.py clean
will clean everything that is not tracked in the repo.
) | ||
|
||
rem Debug build enabled by default | ||
if NOT DEFINED BUILD_DEBUG ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if both BUILD_DEBUG
and BUILD_RELEASE
are not specified, DEBUG
will be used. I think it should default to Release instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It must build both, Debug and Release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First it builds debug, then release.
@ArutyunovG Could you rebase this PR against the master branch? I want to test it through CI. |
6c71633
to
e8327d8
Compare
@peterjc123 |
e8327d8
to
e79b878
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've rebased your changes again due to the changes in the CI side. This PR will be merged automatically if all things go right.
Oh no, CI seems to be stuck in this PR. Would you please open another PR? |
BTW, the CI didn't pass. https://peter-jc.visualstudio.com/peter_jiachen/_build/results?buildId=166&view=logs |
@peterjc123 |
On my PC the build runs about 5 hours. Not sure what happened, that made you think it is stuck though. |
@ArutyunovG Due to an unknown reason, the build of the CI cannot be triggered in this PR. What you could do is to do the following things:
|
-DINCLUDE_EXPERIMENTAL_C10_OPS=OFF ^ | ||
-DBUILD_SHARED_LIBS=ON ^ | ||
-DBUILD_BINARY=ON | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll have to catch errors here, otherwise, the script will complete with exit code 0 even if there are actually errors. Consider using something like if errorlevel 1 exit /b 1
) | ||
|
||
msbuild /p:Configuration=%CONFIG% /p:Platform=x64 /m:%MAX_JOBS% INSTALL.vcxproj /p:PreferredToolArchitecture=x64 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here.
rem Building Release in %CAFFE2_ROOT%\build\Release | ||
if %BUILD_RELEASE% EQU 1 ( | ||
set CONFIG=Release | ||
call %~dp0%msbuild.bat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
rem Building Debug in %CAFFE2_ROOT%\build\Debug | ||
if %BUILD_DEBUG% EQU 1 ( | ||
set CONFIG=Debug | ||
call %~dp0%msbuild.bat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
Hi @peterjc123,
Finished building Caffe2 with Visual Studio 2015 and the script is ready.
At the moment pytorch is cloned from my fork, where the build fully runs. When everything with adapting my pytorch PR will be agreed, of course will switch it to the main repo.
The only exception found at the moment is CUDA 8 in Debug mode. In Release though, it still is able to build.
Successfully tried CUDA 9.0, 9.1, python 2.7 and 3.5, cudnn 7.* in both Debug and Release.