Skip to content

Commit

Permalink
Remove openmp preloads. Remove pytorch FindOpenMP for all platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet committed Jun 22, 2024
1 parent 3165a76 commit f059d37
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 25 deletions.
17 changes: 8 additions & 9 deletions pytorch/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,14 @@ sedinplace 's/char(\(.*\))/\1/g' torch/csrc/jit/serialization/pickler.h
# some windows header defines a macro named "interface"
sedinplace 's/const std::string& interface)/const std::string\& interface_name)/g' torch/csrc/distributed/c10d/ProcessGroupGloo.hpp

if [[ $PLATFORM == windows* ]]; then
# Remove pytorch adaptations of FindOpenMP.cmake that, without iomp and with
# new versions of VS 2019 including -openmp:experimental and libomp, causes
# final binary to be linked to both libomp and vcomp and produce incorrect results.
# Wait for eventual upstream fix, or for cmake 2.30 that allows to choose between -openmp and -openmp:experimental
# and see if choosing experimental works.
rm cmake/Modules/FindOpenMP.cmake
sedinplace 's/include(${CMAKE_CURRENT_LIST_DIR}\/Modules\/FindOpenMP.cmake)/find_package(OpenMP)/g' cmake/Dependencies.cmake
fi
# Remove pytorch adaptations of FindOpenMP.cmake that.
# On Windows without iomp and with new versions of VS 2019, including -openmp:experimental and libomp, causes
# final binary to be linked to both libomp and vcomp and produce incorrect results.
# Wait for eventual upstream fix, or for cmake 2.30 that allows to choose between -openmp and -openmp:experimental
# and see if choosing experimental works. See Issue #1503.
# On Linux, pytorch FindOpenMP.cmake picks llvm libomp over libgomp. See Issue #1504.
rm cmake/Modules/FindOpenMP.cmake
sedinplace 's/include(${CMAKE_CURRENT_LIST_DIR}\/Modules\/FindOpenMP.cmake)/find_package(OpenMP)/g' cmake/Dependencies.cmake

#USE_FBGEMM=0 USE_KINETO=0 USE_GLOO=0 USE_MKLDNN=0 \
"$PYTHON_BIN_PATH" setup.py build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ public Options(

// Create new device instance for specific interface.
public static native @SharedPtr @ByVal org.bytedeco.pytorch.gloo.Device createDeviceForInterface(
@StdString BytePointer _interface);
@StdString BytePointer interface_name);
public static native @SharedPtr @ByVal org.bytedeco.pytorch.gloo.Device createDeviceForInterface(
@StdString String _interface);
@StdString String interface_name);

// Create new device instance for specific hostname or address.
public static native @SharedPtr @ByVal org.bytedeco.pytorch.gloo.Device createDeviceForHostname(
Expand Down
4 changes: 2 additions & 2 deletions pytorch/src/gen/java/org/bytedeco/pytorch/global/torch.java
Original file line number Diff line number Diff line change
Expand Up @@ -77508,11 +77508,11 @@ scalar_t sf(scalar_t x, scalar_t y)
public static final int TORCH_VERSION_MINOR = 3;

/** Indicates the patch version of LibTorch. */
public static final int TORCH_VERSION_PATCH = 0;
public static final int TORCH_VERSION_PATCH = 1;

/** Indicates the version of LibTorch. */
public static final String TORCH_VERSION =
"2.3.0";
"2.3.1";


// Parsed from torch/csrc/api/include/torch/xpu.h
Expand Down
30 changes: 25 additions & 5 deletions pytorch/src/main/java/org/bytedeco/pytorch/presets/torch.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,10 @@

},
exclude = {"openblas_config.h", "cblas.h", "lapacke_config.h", "lapacke_mangling.h", "lapack.h", "lapacke.h", "lapacke_utils.h"},
link = {"c10", "torch_cpu", "torch"},
preload = {"gomp@.1", "iomp5", "omp", "tbb@.2", "asmjit", "fbgemm", "uv"}
preload = { "asmjit", "fbgemm" }
),
@Platform(
value = {"linux", "macosx", "windows"},
link = { "c10", "c10_cuda", "torch_cpu", "torch_cuda", "torch" },
preload = {"gomp@.1", "iomp5", "omp", "tbb@.2", "asmjit", "fbgemm", "uv", "cupti@.12"},
includepath = {"/usr/local/cuda/include", "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/include/"},
preloadpath = {
"/usr/local/cuda-12.3/lib64/",
Expand All @@ -103,9 +100,32 @@
"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/extras/CUPTI/lib64/",
"C:/Program Files/NVIDIA Corporation/NvToolsExt/bin/x64/",
},

linkpath = {
"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/",
"/usr/local/cuda-12.3/lib64/",
"/usr/local/cuda/lib64/",
"/usr/lib64/"
},
extension = "-gpu"
),
@Platform(
value = {"linux", "macosx"},
link = { "c10", "torch", "torch_cpu" }
),
@Platform(
value = "windows",
link = { "c10", "torch", "torch_cpu", "uv" }
),
@Platform(
value = "linux",
extension = "-gpu",
link = { "c10", "torch", "torch_cpu", "c10_cuda", "torch_cuda", "cudart", "cusparse", "cudnn" } // cupti@.12 needed ?
),
@Platform(
value = "windows",
extension = "-gpu",
link = { "c10", "torch", "torch_cpu", "uv", "c10_cuda", "torch_cuda", "cudart", "cusparse", "cudnn" }
)
},
target = "org.bytedeco.pytorch",
global = "org.bytedeco.pytorch.global.torch"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@
// For inclusion in JNI only, not parsed
"ATen/cuda/CUDAGeneratorImpl.h",
},
link = { "cudart", "cusparse", "cudnn" },
linkpath = {
"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64/",
"/usr/local/cuda-12.3/lib64/",
"/usr/local/cuda/lib64/",
"/usr/lib64/"
},
library = "jnitorch"
),
},
Expand Down

0 comments on commit f059d37

Please sign in to comment.