Skip to content

Commit

Permalink
Add sanity checks for torch paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongseok-meta committed Jan 18, 2025
1 parent 48491ea commit da8446a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 32 deletions.
72 changes: 40 additions & 32 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions pymomentum/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,28 @@
# Find dependencies
#===============================================================================

if(NOT DEFINED ENV{CONDA_PREFIX})
message(FATAL_ERROR
"CONDA_PREFIX is not set. pymomentum currently only supports building"
"with Conda/Pixi. Please ensure you are using a Conda or Pixi environment."
)
endif()

set(ENV{NVTOOLSEXT_PATH} "$ENV{CONDA_PREFIX}/include")

if(WIN32)
set(libtorch_base_path $ENV{CONDA_PREFIX}/Lib/site-packages/torch)
else()
set(libtorch_base_path $ENV{CONDA_PREFIX}/lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages/torch)
endif()

if(NOT EXISTS "${libtorch_base_path}")
message(FATAL_ERROR
"PyTorch not found in the expected location: ${libtorch_base_path}"
"Please ensure PyTorch is installed in your Conda/Pixi environment."
)
endif()

find_package(ATen CONFIG REQUIRED HINTS ${libtorch_base_path})
find_package(Torch CONFIG REQUIRED HINTS ${libtorch_base_path})
find_library(torch_python NAMES torch_python HINTS ${libtorch_base_path}/lib/ REQUIRED)
Expand Down

0 comments on commit da8446a

Please sign in to comment.