Commit cce4ec63 authored by Shenggan's avatar Shenggan
Browse files

remove cuda ext option in setup.py

parent 53143f58
...@@ -35,7 +35,7 @@ You can get the FastFold source and install it with setuptools: ...@@ -35,7 +35,7 @@ You can get the FastFold source and install it with setuptools:
```shell ```shell
git clone https://github.com/hpcaitech/FastFold git clone https://github.com/hpcaitech/FastFold
cd FastFold cd FastFold
python setup.py install --cuda_ext python setup.py install
``` ```
## Usage ## Usage
...@@ -83,4 +83,4 @@ torchrun --nproc_per_node=1 perf.py --msa-length 128 --res-length 256 --openfold ...@@ -83,4 +83,4 @@ torchrun --nproc_per_node=1 perf.py --msa-length 128 --res-length 256 --openfold
Cite this paper, if you use FastFold in your research publication. Cite this paper, if you use FastFold in your research publication.
``` ```
``` ```
\ No newline at end of file
import os import os
import subprocess import subprocess
import sys
import torch import torch
from setuptools import setup, find_packages from setuptools import setup, find_packages
...@@ -46,11 +45,6 @@ def append_nvcc_threads(nvcc_extra_args): ...@@ -46,11 +45,6 @@ def append_nvcc_threads(nvcc_extra_args):
return nvcc_extra_args return nvcc_extra_args
def fetch_requirements(path):
with open(path, 'r') as fd:
return [r.strip() for r in fd.readlines()]
if not torch.cuda.is_available(): if not torch.cuda.is_available():
# https://github.com/NVIDIA/apex/issues/486 # https://github.com/NVIDIA/apex/issues/486
# Extension builds after https://github.com/pytorch/pytorch/pull/23408 attempt to query torch.cuda.get_device_capability(), # Extension builds after https://github.com/pytorch/pytorch/pull/23408 attempt to query torch.cuda.get_device_capability(),
...@@ -88,56 +82,50 @@ ext_modules = [] ...@@ -88,56 +82,50 @@ ext_modules = []
# https://github.com/pytorch/pytorch/commit/eb7b39e02f7d75c26d8a795ea8c7fd911334da7e#diff-4632522f237f1e4e728cb824300403ac # https://github.com/pytorch/pytorch/commit/eb7b39e02f7d75c26d8a795ea8c7fd911334da7e#diff-4632522f237f1e4e728cb824300403ac
version_dependent_macros = ['-DVERSION_GE_1_1', '-DVERSION_GE_1_3', '-DVERSION_GE_1_5'] version_dependent_macros = ['-DVERSION_GE_1_1', '-DVERSION_GE_1_3', '-DVERSION_GE_1_5']
if "--cuda_ext" in sys.argv: if CUDA_HOME is None:
sys.argv.remove("--cuda_ext") raise RuntimeError(
"Are you sure your environment has nvcc available? If you're installing within a container from https://hub.docker.com/r/pytorch/pytorch, only images whose names contain 'devel' will provide nvcc."
if CUDA_HOME is None: )
raise RuntimeError( else:
"--cuda_ext was requested, but nvcc was not found. Are you sure your environment has nvcc available? If you're installing within a container from https://hub.docker.com/r/pytorch/pytorch, only images whose names contain 'devel' will provide nvcc." check_cuda_torch_binary_vs_bare_metal(CUDA_HOME)
)
else: def cuda_ext_helper(name, sources, extra_cuda_flags):
check_cuda_torch_binary_vs_bare_metal(CUDA_HOME) return CUDAExtension(
name=name,
def cuda_ext_helper(name, sources, extra_cuda_flags): sources=[
return CUDAExtension( os.path.join('fastfold/model/kernel/cuda_native/csrc', path) for path in sources
name=name, ],
sources=[ include_dirs=[
os.path.join('fastfold/model/kernel/cuda_native/csrc', path) for path in sources os.path.join(this_dir, 'fastfold/model/kernel/cuda_native/csrc/include')
], ],
include_dirs=[ extra_compile_args={
os.path.join(this_dir, 'fastfold/model/kernel/cuda_native/csrc') 'cxx': ['-O3'] + version_dependent_macros,
], 'nvcc':
extra_compile_args={ append_nvcc_threads(['-O3', '--use_fast_math'] + version_dependent_macros +
'cxx': ['-O3'] + version_dependent_macros, extra_cuda_flags)
'nvcc': })
append_nvcc_threads(['-O3', '--use_fast_math'] + version_dependent_macros +
extra_cuda_flags)
})
cc_flag = ['-gencode', 'arch=compute_70,code=sm_70']
_, bare_metal_major, _ = get_cuda_bare_metal_version(CUDA_HOME)
if int(bare_metal_major) >= 11:
cc_flag = ['-gencode', 'arch=compute_70,code=sm_70'] cc_flag.append('-gencode')
_, bare_metal_major, _ = get_cuda_bare_metal_version(CUDA_HOME) cc_flag.append('arch=compute_80,code=sm_80')
if int(bare_metal_major) >= 11:
cc_flag.append('-gencode') extra_cuda_flags = [
cc_flag.append('arch=compute_80,code=sm_80') '-std=c++14', '-maxrregcount=50', '-U__CUDA_NO_HALF_OPERATORS__',
'-U__CUDA_NO_HALF_CONVERSIONS__', '--expt-relaxed-constexpr', '--expt-extended-lambda'
extra_cuda_flags = [ ]
'-std=c++14', '-maxrregcount=50', '-U__CUDA_NO_HALF_OPERATORS__',
'-U__CUDA_NO_HALF_CONVERSIONS__', '--expt-relaxed-constexpr', '--expt-extended-lambda' ext_modules.append(
] cuda_ext_helper('fastfold_layer_norm_cuda',
['layer_norm_cuda.cpp', 'layer_norm_cuda_kernel.cu'],
ext_modules.append( extra_cuda_flags + cc_flag))
cuda_ext_helper('fastfold_layer_norm_cuda',
['layer_norm_cuda.cpp', 'layer_norm_cuda_kernel.cu'], ext_modules.append(
extra_cuda_flags + cc_flag)) cuda_ext_helper('fastfold_softmax_cuda', ['softmax_cuda.cpp', 'softmax_cuda_kernel.cu'],
extra_cuda_flags + cc_flag))
ext_modules.append(
cuda_ext_helper('fastfold_softmax_cuda', ['softmax_cuda.cpp', 'softmax_cuda_kernel.cu'],
extra_cuda_flags + cc_flag))
install_requires = fetch_requirements('./requirements.txt')
setup( setup(
name='fastfold', name='fastfold',
...@@ -145,13 +133,12 @@ setup( ...@@ -145,13 +133,12 @@ setup(
packages=find_packages(exclude=( packages=find_packages(exclude=(
'assets', 'assets',
'benchmark', 'benchmark',
'notebooks',
'scripts',
'*.egg-info', '*.egg-info',
)), )),
description= description=
'Optimizing Protein Structure Prediction Model Training and Inference on GPU Clusters', 'Optimizing Protein Structure Prediction Model Training and Inference on GPU Clusters',
ext_modules=ext_modules, ext_modules=ext_modules,
package_data={'fastfold': ['model/kernel/cuda_native/csrc/*']},
cmdclass={'build_ext': BuildExtension} if ext_modules else {}, cmdclass={'build_ext': BuildExtension} if ext_modules else {},
install_requires=install_requires, install_requires=['einops', 'colossalai'],
) )
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment