Skip to content
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

Closed
wants to merge 7 commits into from

Conversation

ArutyunovG
Copy link
Contributor

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.

@ArutyunovG
Copy link
Contributor Author

Have to merge image_input_op.h to resolve conflict with the main branch.

@ArutyunovG ArutyunovG closed this Nov 7, 2018
@ArutyunovG
Copy link
Contributor Author

Ok, it runs after mege.
I have some 18 CI issues that don't know hot to resolve though. Probably you can tell me, what's wrong there? They don't seem related to build.

@ArutyunovG ArutyunovG reopened this Nov 8, 2018
Copy link
Owner

@peterjc123 peterjc123 left a 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%
Copy link
Owner

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 (
Copy link
Owner

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"?

Copy link
Owner

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 "" (
Copy link
Owner

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?

Copy link
Contributor Author

@ArutyunovG ArutyunovG Nov 8, 2018

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 "" (
Copy link
Owner

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 "" (
Copy link
Owner

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
Copy link
Owner

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 (
Copy link
Owner

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 (
Copy link
Owner

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.

rem Building Debug in %CAFFE2_ROOT%\build\Debug
if %BUILD_DEBUG% EQU 1 (
set CONFIG=Debug
call msbuild.bat
Copy link
Owner

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.

rem Building Release in %CAFFE2_ROOT%\build\Release
if %BUILD_RELEASE% EQU 1 (
set CONFIG=Release
call msbuild.bat
Copy link
Owner

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 "" (
Copy link
Owner

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,


rem msbuild /m: option value
if NOT DEFINED MAX_JOBS (
set MAX_JOBS=6
Copy link
Owner

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?

Copy link
Contributor Author

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?

Copy link
Owner

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.

exit
)

msbuild /p:Configuration=%CONFIG% /p:Platform=x64 /m:%MAX_JOBS% INSTALL.vcxproj /p:PreferredToolArchitecture=x64
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: newline here


if %REBUILD% EQU 1 (
if exist %CAFFE2_ROOT%\build (
rmdir %CAFFE2_ROOT%\build /s /q
Copy link
Owner

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?

Copy link
Contributor Author

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?

Copy link
Owner

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 (
Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@peterjc123
Copy link
Owner

@ArutyunovG Could you rebase this PR against the master branch? I want to test it through CI.

@ArutyunovG
Copy link
Contributor Author

@peterjc123
Rebased, check if everything is correct with the rebase, please.

peterjc123
peterjc123 previously approved these changes Nov 10, 2018
Copy link
Owner

@peterjc123 peterjc123 left a 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.

@peterjc123 peterjc123 closed this Nov 10, 2018
@peterjc123 peterjc123 reopened this Nov 10, 2018
@peterjc123
Copy link
Owner

Oh no, CI seems to be stuck in this PR. Would you please open another PR?

@peterjc123 peterjc123 changed the title Caffe2 building Add Caffe2 building scripts Nov 10, 2018
@peterjc123
Copy link
Owner

@ArutyunovG
Copy link
Contributor Author

ArutyunovG commented Nov 10, 2018

@peterjc123
Could you please explain what needs to be done on my side?
What PR to open and what are the problems with CI?
BTW edit:
This is my Skype for faster communication on technical issues, feel free to add if there is a need at some point: the_last_inspiration.

@ArutyunovG
Copy link
Contributor Author

On my PC the build runs about 5 hours. Not sure what happened, that made you think it is stuck though.
Waiting for your answer.

@peterjc123
Copy link
Owner

@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:

  1. Close this PR
  2. Create a new branch that points to the current master
  3. Cherry-pick every commit in this PR
  4. Open a new PR with that new branch

-DINCLUDE_EXPERIMENTAL_C10_OPS=OFF ^
-DBUILD_SHARED_LIBS=ON ^
-DBUILD_BINARY=ON

Copy link
Owner

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

Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@ArutyunovG ArutyunovG closed this Nov 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants