Skip to content

Commit

Permalink
add torch to external dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tjira committed Jul 27, 2024
1 parent efe739b commit e9bf528
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,25 @@ jobs:
- uses: actions/checkout@v4

- name: Install Packages
run: sudo apt install -y libboost-dev libeigen3-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev
run: sudo apt install -y libboost-dev libeigen3-dev

- name: Build Libfftw
run: ./script/libfftw.sh

- name: Build Libtorch
run: ./script/libtorch.sh

- name: Build Libint
run: ./script/libint.sh

- name: Configure Acorn
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build Acorn
run: |
export CPLUS_INCLUDE_PATH="$PWD/libfftw/install/include:$PWD/libint/install/include:$CPLUS_INCLUDE_PATH"
export LIBRARY_PATH="$PWD/libfftw/install/lib:$PWD/libint/install/lib:$LIBRARY_PATH"
export CMAKE_PREFIX_PATH="$PWD/libtorch/install:$CMAKE_PREFIX_PATH"
cmake --build build --parallel 2
- name: Run Tests
Expand Down
9 changes: 0 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
set(CMAKE_CXX_FLAGS_DEBUG "-g -pg -Og -Wall -Wextra --coverage")
set(CMAKE_CXX_FLAGS_RELEASE "-s -O3 -flto=auto -march=native")

# declare Torch library for fast tensor contractions
FetchContent_Declare(torch SYSTEM DOWNLOAD_EXTRACT_TIMESTAMP TRUE URL https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.4.0%2Bcpu.zip)

# download the Torch library
FetchContent_MakeAvailable(torch)

# add torch prefix path
set(Torch_DIR ${torch_SOURCE_DIR}/share/cmake/Torch)

# include directories
include_directories(example/diagram include lib)

Expand Down
4 changes: 1 addition & 3 deletions script/libtorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
wget https://github.com/pytorch/pytorch/releases/download/v2.4.0/pytorch-v2.4.0.tar.gz && tar -xzvf pytorch-v2.4.0.tar.gz && mv pytorch-v2.4.0 libtorch && rm pytorch-v2.4.0.tar.gz

# configure libtorch
cd libtorch && cmake -B build -DBUILD_PYTHON=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/install" -DUSE_FBGEMM=OFF && cd ..
cd libtorch && cmake -B build -DBUILD_PYTHON=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/install" -DUSE_DISTRIBUTED=OFF -DUSE_FBGEMM=OFF -DUSE_OPENMP=OFF && cd ..

# build and install libtorch
cd libtorch && cmake --build build --parallel 2 && cmake --install build && cd ..

# pip install pyyaml typing-extensions

0 comments on commit e9bf528

Please sign in to comment.