-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pytorch-fortran] Add spack recipe (#816)
- Loading branch information
1 parent
2b1ad6a
commit abe6427
Showing
5 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other | ||
# Spack Project Developers. See the top-level COPYRIGHT file for details. | ||
# | ||
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
||
from spack import * | ||
import shutil | ||
|
||
|
||
class Libtorch(Package): | ||
''' | ||
PyTorch is a Python package that provides two high-level features: | ||
- Tensor computation (like NumPy) with strong GPU acceleration | ||
- Deep neural networks built on a tape-based autograd system | ||
''' | ||
|
||
homepage = "https://pytorch.org/" | ||
url = "https://download.pytorch.org/libtorch/cu117/libtorch-cxx11-abi-shared-with-deps-2.0.1%2Bcu117.zip" | ||
|
||
maintainers = ['juckerj'] | ||
|
||
version('2.0.1', | ||
url=url, | ||
sha256= | ||
'262f723ee5a2caac977e089bc06e9d840ca33d70706fbd4a2fca04995bb94eb4') | ||
|
||
phases = ['install'] | ||
|
||
def install(self, spec, prefix): | ||
# can't use Spack convenience-function 'install_tree' because it uses | ||
# shutil.copy2 under the hood. For an unknown reason installing from | ||
# the unzipped tarbal only works using shutil.copy. | ||
shutil.copytree('lib', | ||
prefix.lib, | ||
symlinks=True, | ||
copy_function=shutil.copy) | ||
shutil.copytree('include', | ||
prefix.include, | ||
symlinks=True, | ||
copy_function=shutil.copy) | ||
shutil.copytree('share', | ||
prefix.share, | ||
symlinks=True, | ||
copy_function=shutil.copy) | ||
shutil.copytree('bin', | ||
prefix.bin, | ||
symlinks=True, | ||
copy_function=shutil.copy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other | ||
# Spack Project Developers. See the top-level COPYRIGHT file for details. | ||
# | ||
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
||
# | ||
from spack import * | ||
|
||
|
||
class PytorchFortranProxy(CMakePackage): | ||
''' | ||
Pytorch Fortran bindings - C++ Backend | ||
The goal of this code is to provide Fortran HPC codes with a simple way to use | ||
Pytorch deep learning framework. We want Fortran developers to take advantage | ||
of rich and optimized Torch ecosystem from within their existing codes. | ||
''' | ||
|
||
homepage = "https://github.com/alexeedm/pytorch-fortran" | ||
url = "https://github.com/alexeedm/pytorch-fortran.git" | ||
|
||
version('0.4', git=url, tag='v0.4') | ||
|
||
maintainers = ['juckerj'] | ||
|
||
depends_on('cuda') | ||
depends_on('libtorch') | ||
depends_on('py-pybind11') | ||
|
||
root_cmakelists_dir = 'src/proxy_lib' | ||
|
||
def cmake_args(self): | ||
args = [ | ||
self.define('OPENACC', 1), | ||
self.define('CUDA_TOOLKIT_ROOT_DIR', self.spec['cuda'].prefix), | ||
self.define('TORCH_CUDA_ARCH_LIST', "6.0") | ||
] | ||
|
||
return args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other | ||
# Spack Project Developers. See the top-level COPYRIGHT file for details. | ||
# | ||
# SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
|
||
# | ||
from spack import * | ||
|
||
|
||
class PytorchFortran(CMakePackage): | ||
''' | ||
Pytorch Fortran bindings - Fortran Frontend | ||
The goal of this code is to provide Fortran HPC codes with a simple way to use | ||
Pytorch deep learning framework. We want Fortran developers to take advantage | ||
of rich and optimized Torch ecosystem from within their existing codes. | ||
''' | ||
|
||
homepage = "https://github.com/alexeedm/pytorch-fortran" | ||
url = "https://github.com/alexeedm/pytorch-fortran.git" | ||
|
||
version('0.4', git=url, tag='v0.4') | ||
|
||
maintainers = ['juckerj'] | ||
|
||
depends_on('pytorch-fortran-proxy') | ||
|
||
root_cmakelists_dir = 'src/f90_bindings' | ||
|
||
def cmake_args(self): | ||
args = [self.define('OPENACC', 1)] | ||
|
||
return args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -489,6 +489,12 @@ def test_install_c2sm_master_nvhpc(self): | |
) | ||
|
||
|
||
class LibTorchTest(unittest.TestCase): | ||
|
||
def test_install_default(self): | ||
spack_install('libtorch') | ||
|
||
|
||
@pytest.mark.no_tsa # Test is too expensive. It takes over 5h. | ||
class LibCdiPioTest(unittest.TestCase): | ||
|
||
|
@@ -557,6 +563,22 @@ def test_install_version_0_1(self): | |
spack_install_and_test('omni-xmod-pool @0.1') | ||
|
||
|
||
@pytest.mark.no_tsa | ||
class PytorchFortranTest(unittest.TestCase): | ||
|
||
def test_install_version_0_4(self): | ||
spack_install( | ||
'[email protected]%nvhpc ^[email protected]%gcc ^[email protected]' | ||
) | ||
|
||
|
||
@pytest.mark.no_tsa | ||
class PytorchFortranProxyTest(unittest.TestCase): | ||
|
||
def test_install_version_0_4(self): | ||
spack_install('[email protected]%gcc ^[email protected]') | ||
|
||
|
||
class PyBlackTest(unittest.TestCase): | ||
|
||
def test_install_default(self): | ||
|