Commit Graph

39 Commits

Author SHA1 Message Date
peter
3bdc4a37ed CMake script cleanup - mixed case for function names (#35589)
Summary:
Running the following code.
```bash
cmake --help-command-list |
grep -v "cmake version" |
while read c; do
    echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(cmake/Modules/|cmake/Modules_CUDA_fix/)' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
```
cmake-lint is too sensitive about mixed case so I didn't switch the check on.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35589

Differential Revision: D20735648

Pulled By: ezyang

fbshipit-source-id: a09a60a7ce921bb198575a35335faa299bd10b66
2020-03-30 11:37:02 -07:00
Nikita Shulga
b9adbb5002 Fix/relax CMake linter rules (#35574)
Summary:
Ignore mixed upper-case/lower-case style for now
Fix space between function and its arguments violation
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35574

Test Plan: CI

Differential Revision: D20712969

Pulled By: malfet

fbshipit-source-id: 0012d430aed916b4518599a0b535e82d15721f78
2020-03-27 16:52:33 -07:00
peter
45c9ed825a Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521)
Summary:
Running commands:
```bash
shopt -s globstar

sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i caffe2/**/CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i torch/**/CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i c10/**/CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i cmake/**/*.cmake
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i cmake/**/*.cmake.in
```
We may further convert all the commands into lowercase according to the following issue: 77543bde41.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35521

Differential Revision: D20704382

Pulled By: malfet

fbshipit-source-id: 42186b9b1660c34428ab7ceb8d3f7a0ced5d2e80
2020-03-27 14:25:17 -07:00
Owen Anderson
f204e3e624 Pass WERROR to CMake as an explicit parameter rather than an env var.
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/16465

Differential Revision: D13853949

Pulled By: resistor

fbshipit-source-id: 71ccf90a2824ad21c9f26dd753b186f30435d82a
2019-01-28 20:57:18 -08:00
Zachary DeVito
92314c83fa re-enable copy of python files, but be careful that the copy is only … (#14982)
Summary:
…done once

This allow no-op build to work correctly even when BUILD_CAFFE2_OPS is on.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14982

Differential Revision: D13413960

Pulled By: zdevito

fbshipit-source-id: 6e5412a8c375af8a47c76f548cdd31cff15f3853
2018-12-11 16:54:08 -08:00
Orion Reblitz-Richardson
02d7c88fa4 Unify versions across setup.py, libtorch, and libcaffe2 (#12053)
Summary:
This unifies our versions across setup.py, libtorch, and libcaffe2. CMake has a default version (bumped to 1.0.0) that can be overridden by setup.py. The versions are also printed as a part of cmake/Summary.cmake to make sure they are correct.

cc Yangqing ezyang soumith goldsborough pjh5
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12053

Differential Revision: D10041878

Pulled By: orionr

fbshipit-source-id: a98a01771f6c008d1016ab63ab785c3a88c3ddb0
2018-09-26 08:55:06 -07:00
Yangqing Jia
40109b16d0 Remove caffe1 specific proto (#10380)
Summary:
This was used as a convenient way for us to convert c1 models. Now that conversion is more or less done, we should probably require any users who need to convert c1 models to explicitly install c1. This PR removes the explicit c1 proto (which was copied from c1) in favor of explicit installation.

Note that caffe_translator would still work properly, only difference is that now users need to install c1 separately.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/10380

Differential Revision: D9267981

Pulled By: Yangqing

fbshipit-source-id: a6ce5d9463e6567976da83f2d08b2c3d94d14390
2018-08-10 11:10:26 -07:00
Jesse Hellemn
c6376cf999 A reasonable way to detect Python include dirs and library
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/9361

Reviewed By: ml7

Differential Revision: D8837706

Pulled By: pjh5

fbshipit-source-id: 6979f9f37709c23e72b9169531787a60f3b37254
2018-07-13 11:25:00 -07:00
Mingzhe Li
7d8b532c1f Fix CUDA build failures (#9347)
Summary:
Breaking this out of #8338

This fixes some CUDA related build and runtime issues after BUILD_CAFFE2 and BUILD_ATEN are removed.

cc orionr
Pull Request resolved: https://github.com/pytorch/pytorch/pull/9347

Reviewed By: orionr

Differential Revision: D8806954

Pulled By: mingzhe09088

fbshipit-source-id: 9f8e3feee06478d1ac2deb30796939453352d388
2018-07-11 13:39:59 -07:00
Mingzhe Li
a70a90b28f Fix pytorch linux build issues (#9273)
Summary:
Breaking out of #8338

This fixes the build issues with pytorch on linux machines after BUILD_CAFFE2 and BUILD_ATEN are removed.

cc orionr
Pull Request resolved: https://github.com/pytorch/pytorch/pull/9273

Reviewed By: orionr

Differential Revision: D8768869

Pulled By: mingzhe09088

fbshipit-source-id: 2730426ed1bed398eb5dc804c7348aeeb27c93d3
2018-07-09 14:41:36 -07:00
Tongzhou Wang
f935ba1b05 [build] Enable clang-specific warnings only when using clang (#8869)
* Wraps clang only warnings in an if

* add back -Wno-missing-field-initializers
2018-06-26 11:09:25 -04:00
Sebastian Meßmer
cca247635c
First version of dispatcher (#8713) 2018-06-25 13:11:53 -07:00
Sebastian Meßmer
efba555a38
c10 build setup (#8264)
* Move c10/ to caffe2/dispatch/

* Set up caffe2/utils directory
2018-06-08 12:11:17 -07:00
Paul Jesse Hellemn
2e32e8df75
Statically linking CUDA for Anaconda builds (#6680)
* Statically linking CUDA for Anaconda builds

* typo

* Adding a summary line

* Comments

* Typo fix

* Fix faulty parameter passing

* Removing problem CUDA modules for now

* Fixing unused debugging function

* Turning off static cuda linking until script changes are in

* Disabling mkl
2018-04-25 18:22:54 -05:00
Yangqing Jia
8b28ab4858 Add option cache to speed up cmake build (#6737)
* Add option cache to speed up cmake build

* Also only run autogen_init_py_files once
2018-04-20 19:55:39 -07:00
harrysummer
4cde7c0f09 Modify cmake dedent function to make it compatible with Windows. (#6296) 2018-04-05 21:37:12 -04:00
Yangqing Jia
fdfe1d09a0 Explicitly require listing additional libraries if a binary needs things beyond Caffe2_MAIN_LIBS (#2110) 2018-03-02 16:29:13 -08:00
Koan-Sin Tan
24dee1515c add a rule back for non-Android platforms
`-DBUILD_TEST=ON -DBUILD_BINARY=ON -DUSE_OBSERVERS=ON -DBUILD_OBSERVERS=ON`
should work for both Andorid and non-Android platformas (e.g., Ubuntu)
2018-03-02 20:31:33 +01:00
Koan-Sin Tan
9befaf14ea fix -DBUILD_TEST=ON -DBUILD_BINARY=ON for Android
make
```
./script/build_android -DBUILD_TEST=ON -DBUILD_BINARY=ON
```
work
2018-03-02 20:31:33 +01:00
Yangqing Jia
3d070e78fe Fix cmake dependency error in static library case. Peer coded with @bddppq (#2078)
* Fix cmake dependency error in static library case. Peer coded with @bddppq

* Temporarily add back the private dependencies to the binary targets
2018-02-28 01:33:59 -08:00
Yangqing Jia
178c4be295 [wip] Cmake modernization (#2066)
* cmake target - work in progress

* wip cmake public targets

* Add missing INTERFACE keyword

* Add cuda public dependencies

* Add dependency for test targets
2018-02-27 20:42:37 -08:00
Yinghai Lu
0955e791d3 Fix caffe_add_whole_archive_flag in cmake (#2062) 2018-02-27 15:04:01 -08:00
Yangqing Jia
c3320887fe [cmake] try removing caffe2_include_directories hack (#2050) 2018-02-26 12:45:06 -08:00
Yangqing Jia
1f9df59de9 Move caffe_option to proper cmake_dependent_option (#2049) 2018-02-24 23:31:36 -08:00
Paul Jesse Hellemn
0f68eac94a Fixing an error building with CUDA on windows (#2004)
* Fixing an error building with CUDA on windows

* Fixing cublas issue too
2018-02-22 23:37:02 -08:00
Yinghai Lu
86803004e3 Fix cmake function to resolve libraries correctly
Summary:
Previous behavior may fail to resolve the correct library name. A rework of https://github.com/caffe2/caffe2/pull/1935 as it was messed up in the rebase...
Closes https://github.com/caffe2/caffe2/pull/1950

Reviewed By: bddppq

Differential Revision: D6974530

Pulled By: yinghai

fbshipit-source-id: 924b653e8ac0b68c46341edfd3eb05d9cc0155f2
2018-02-12 22:22:55 -08:00
joncrall
61ad0e486b cmake: python packages now install to the cannonical directory
Summary:
Addresses issue #1676

Now when `make install` is run, the `caffe2` (and `caffe`) python modules will be installed into the correct site-packages directory (relative to the prefix) instead of directly in the prefix.
Closes https://github.com/caffe2/caffe2/pull/1677

Reviewed By: pietern

Differential Revision: D6710247

Pulled By: bddppq

fbshipit-source-id: b49167d48fd94d87f7b7c1ebf0f187ec6a203470
2018-02-05 17:05:34 -08:00
Jesse Hellemn
4357dee097 Adapting conda build to work for ubuntu and adding a flag to control precedence of Anaconda include dirs
Summary:
This should fix Protobuf version problems on all Anaconda builds by putting include directories under Anaconda before all other include directories.
Closes https://github.com/caffe2/caffe2/pull/1728

Reviewed By: orionr

Differential Revision: D6698435

Pulled By: pjh5

fbshipit-source-id: f73f4a5ebb4ca91db14770a88a704ace69d37ba4
2018-01-11 12:01:04 -08:00
Yangqing Jia
f14d75c7ef Proper versioning and misc CMake improvements
Summary:
This brings proper versioning in Caffe2: instead of manual version macros, this puts the version information in CMake (replacing the TODO bwasti line) and uses macros.h.in to then generate the version in the C++ header.

A few misc updates:
- Removed the mac os rpath, verified on local macbook that it is no longer needed.
- Misc updates for caffe2 ready:
  - Mapped cmake/Cuda.cmake with gloo's setting.
  - upstreamed third_party/nccl so it builds with cuda 9.
- Separated the Caffe2 cpu dependencies and cuda dependencies
  - now libCaffe2_CPU.so do not depend on any cuda libs.
  - caffe2 python extensions now depend on cpu and gpu separately too.
- Reduced the number of unused functions in Utils.cmake
Closes https://github.com/caffe2/caffe2/pull/1256

Reviewed By: dzhulgakov

Differential Revision: D5899210

Pulled By: Yangqing

fbshipit-source-id: 36366e47366c3258374d646cf410b5f49f95767b
2017-09-26 08:52:21 -07:00
Pieter Noordhuis
523d8af26e CMake helper to deprioritize Anaconda include path
Summary:
I ran into an issue where a subset of packages were found in the
Anaconda path. This path also contained includes for other packages
and the Anaconda path inadvertently took precendence over the intended
include path. The new `caffe2_include_directories` helper is a hacky
attempt to "fix" this by deprioritizing Anaconda paths in the hope
that intended include paths are searched before Anaconda.
Closes https://github.com/caffe2/caffe2/pull/1121

Reviewed By: Yangqing

Differential Revision: D5701819

Pulled By: pietern

fbshipit-source-id: 908284cd4ea6c8167774e4e3fcc4dc0ca8a23110
2017-08-25 10:32:59 -07:00
Luke Yeager
e902620620 cmake: relative paths for install()
Summary:
I discovered this while investigating more build-caching issues like https://github.com/caffe2/caffe2/pull/1103.

> If a relative path is given it is interpreted relative to the value of the CMAKE_INSTALL_PREFIX variable.
https://cmake.org/cmake/help/v3.0/command/install.html

This is a non-functional change - it just makes the code a bit easier to read. I verified locally that the resulting install directories are identical.
Closes https://github.com/caffe2/caffe2/pull/1111

Differential Revision: D5677328

Pulled By: Yangqing

fbshipit-source-id: 9bb1bfe85fc0bc54a9b7ce33cc31e45ea061d21e
2017-08-22 09:52:09 -07:00
Yangqing Jia
e03e14a71e Clean up binary build cmake script
Summary:
After the change we will be able to simply define targets and find dependencies.
Closes https://github.com/caffe2/caffe2/pull/640

Differential Revision: D5121700

Pulled By: Yangqing

fbshipit-source-id: 2d21e1afbccb09614054feccdd1bef55cbe3b035
2017-05-24 13:47:26 -07:00
Yangqing Jia
1741fd839f Re-apply windows diff D4657831
Summary:
(Note: previous revert was due to a race condition between D4657831 and
D4659953 that I failed to catch.)

After this, we should have contbuild guarding the Windows build both with
and without CUDA.

This includes a series of changes that are needed to make Windows build,
specifically:

(1) Various flags that are needed in the cmake system, specially dealing
with /MD, /MT, cuda, cudnn, whole static linking, etc.
(2) Contbuild scripts based on appveyo.
(3) For Windows build, note that one will need to use "cmake --build" to
build stuff so that the build type is consistent between configuration and
actual build. see scripts\build_windows.bat for details.
(4) In logging.h, ERROR is already defined by Windows. I don't have a good
solution now, and as a result, LOG(ERROR) on windows is going to be
LOG(INFO).
(5) variable length array is not supported by MSVC (and it is not part of
C++ standard). As a result I replaced them with vectors.
(6) sched.h is not available on Windows, so akyrola 's awesome simple
async net might encounter some slowdown due to no affinity setting on
Windows.
(7) MSVC has a bug that does not work very well with template calls inide
a templated function call, which is a known issue that should be fixed in
MSVC 2017. However for now this means changes to conv_op_impl.h and
recurrent_net_op.h. No actual functionalities are changed.
(8) std host function calls are not supported in CUDA8+MSVC, so I changed
lp_pool (and maybe a few others) to use cuda device functions.
(9) The current Scale and Axpy has heavy templating that does not work
well with MSVC. As a result I reverted azzolini 's changes to the Scale
and Axpy interface, moved the fixed-length version to ScaleFixedSize and
AxpyFixedSize.
(10) CUDA + MSVC does not deal with Eigen well, so I guarded all Eigen
parts to only the non-CUDA part.
(11) In conclusion, it is fun but painful to deal with visual c++.

Differential Revision: D4666745

fbshipit-source-id: 3c9035083067bdb19a16d9c345c1ce66b6a86600
2017-03-07 11:02:12 -08:00
Avani Nandini
039c3cf0ba Revert D4657831: [caffe2][PR] Changes for Windows build to pass.
Summary: This reverts commit 070ded372ed78a7e3e3919fdffa1d337640f146e

Differential Revision: D4657831

fbshipit-source-id: 3a0fb403936a9257776d637ce3ba5dbd81e1119f
2017-03-06 21:02:36 -08:00
Yangqing Jia
7b8c7b11d2 Changes for Windows build to pass.
Summary:
After this, we should have contbuild guarding the Windows build both with
and without CUDA.

This includes a series of changes that are needed to make Windows build,
specifically:

(1) Various flags that are needed in the cmake system, specially dealing
with /MD, /MT, cuda, cudnn, whole static linking, etc.
(2) Contbuild scripts based on appveyo.
(3) For Windows build, note that one will need to use "cmake --build" to
build stuff so that the build type is consistent between configuration and
actual build. see scripts\build_windows.bat for details.
(4) In logging.h, ERROR is already defined by Windows. I don't have a good
solution now, and as a result, LOG(ERROR) on windows is going to be
LOG(INFO).
(5) variable length array is not supported by MSVC (and it is not part of
C++ standard). As a result I replaced them with vectors.
(6) sched.h is not available on Windows, so akyrola 's awesome simple
async net might encounter some slowdown due to no affinity setting on
Windows.
(7) MSVC has a
Closes https://github.com/caffe2/caffe2/pull/183

Reviewed By: ajtulloch

Differential Revision: D4657831

Pulled By: Yangqing

fbshipit-source-id: 070ded372ed78a7e3e3919fdffa1d337640f146e
2017-03-06 20:03:37 -08:00
Yangqing Jia
e3ea3e8c12 MKL convolution operator
Summary: Closes https://github.com/caffe2/caffe2/pull/102

Differential Revision: D4448886

Pulled By: Yangqing

fbshipit-source-id: 914d11cd79107895a9755154df3526fcf71a31ea
2017-01-23 09:59:30 -08:00
Yangqing Jia
be1224c0a7 cmake: allow execution of python files without make install
Summary:
This will help issues like #99
Closes https://github.com/caffe2/caffe2/pull/101

Differential Revision: D4448397

Pulled By: Yangqing

fbshipit-source-id: ede3fafc1b1314886583e8ea38948bb31e69347b
2017-01-22 13:29:37 -08:00
Yangqing Jia
1cd166d330 CMake completions work
Summary: Closes https://github.com/caffe2/caffe2/pull/88

Differential Revision: D4404292

Pulled By: bwasti

fbshipit-source-id: 8a4351c2dee5136aaa12b90f1a61fd7afee51994
2017-01-11 16:59:22 -08:00
Simon Layton
52f09fe2c9 Initial building with deps 2016-12-13 09:29:01 -05:00