Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
OpenFold
Commits
3c674b71
Unverified
Commit
3c674b71
authored
Jan 28, 2023
by
Gustaf Ahdritz
Committed by
GitHub
Jan 28, 2023
Browse files
Merge pull request #252 from p-durandin/fold-cpu
Fix for CPU only install
parents
2ef7893a
975ec36c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
30 deletions
+80
-30
openfold/utils/kernel/csrc/softmax_cuda_stub.cpp
openfold/utils/kernel/csrc/softmax_cuda_stub.cpp
+36
-0
setup.py
setup.py
+44
-30
No files found.
openfold/utils/kernel/csrc/softmax_cuda_stub.cpp
0 → 100644
View file @
3c674b71
// Copyright 2021 AlQuraishi Laboratory
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// modified from fastfold/model/fastnn/kernel/cuda_native/csrc/softmax_cuda.cpp
#include <torch/extension.h>
void
attn_softmax_inplace_forward_
(
at
::
Tensor
input
,
long
long
rows
,
int
cols
)
{
throw
std
::
runtime_error
(
"attn_softmax_inplace_forward_ not implemented on CPU"
);
};
void
attn_softmax_inplace_backward_
(
at
::
Tensor
output
,
at
::
Tensor
d_ov
,
at
::
Tensor
values
,
long
long
rows
,
int
cols_output
,
int
cols_values
)
{
throw
std
::
runtime_error
(
"attn_softmax_inplace_backward_ not implemented on CPU"
);
};
\ No newline at end of file
setup.py
View file @
3c674b71
...
@@ -16,7 +16,7 @@ import os
...
@@ -16,7 +16,7 @@ import os
from
setuptools
import
setup
,
Extension
,
find_packages
from
setuptools
import
setup
,
Extension
,
find_packages
import
subprocess
import
subprocess
from
torch.utils.cpp_extension
import
BuildExtension
,
CUDAExtension
,
CUDA_HOME
from
torch.utils.cpp_extension
import
BuildExtension
,
CppExtension
,
CUDAExtension
,
CUDA_HOME
from
scripts.utils
import
get_nvidia_cc
from
scripts.utils
import
get_nvidia_cc
...
@@ -37,14 +37,18 @@ extra_cuda_flags = [
...
@@ -37,14 +37,18 @@ extra_cuda_flags = [
]
]
def
get_cuda_bare_metal_version
(
cuda_dir
):
def
get_cuda_bare_metal_version
(
cuda_dir
):
raw_output
=
subprocess
.
check_output
([
cuda_dir
+
"/bin/nvcc"
,
"-V"
],
universal_newlines
=
True
)
if
cuda_dir
==
None
:
output
=
raw_output
.
split
()
print
(
"CUDA is not found, cpu version is installed"
)
release_idx
=
output
.
index
(
"release"
)
+
1
return
None
,
-
1
,
0
release
=
output
[
release_idx
].
split
(
"."
)
else
:
bare_metal_major
=
release
[
0
]
raw_output
=
subprocess
.
check_output
([
cuda_dir
+
"/bin/nvcc"
,
"-V"
],
universal_newlines
=
True
)
bare_metal_minor
=
release
[
1
][
0
]
output
=
raw_output
.
split
()
release_idx
=
output
.
index
(
"release"
)
+
1
return
raw_output
,
bare_metal_major
,
bare_metal_minor
release
=
output
[
release_idx
].
split
(
"."
)
bare_metal_major
=
release
[
0
]
bare_metal_minor
=
release
[
1
][
0
]
return
raw_output
,
bare_metal_major
,
bare_metal_minor
compute_capabilities
=
set
([
compute_capabilities
=
set
([
(
3
,
7
),
# K80, e.g.
(
3
,
7
),
# K80, e.g.
...
@@ -70,22 +74,8 @@ for major, minor in list(compute_capabilities):
...
@@ -70,22 +74,8 @@ for major, minor in list(compute_capabilities):
extra_cuda_flags
+=
cc_flag
extra_cuda_flags
+=
cc_flag
if
bare_metal_major
!=
-
1
:
setup
(
modules
=
[
CUDAExtension
(
name
=
'openfold'
,
version
=
'1.0.0'
,
description
=
'A PyTorch reimplementation of DeepMind
\'
s AlphaFold 2'
,
author
=
'Gustaf Ahdritz & DeepMind'
,
author_email
=
'gahdritz@gmail.com'
,
license
=
'Apache License, Version 2.0'
,
url
=
'https://github.com/aqlaboratory/openfold'
,
packages
=
find_packages
(
exclude
=
[
"tests"
,
"scripts"
]),
include_package_data
=
True
,
package_data
=
{
"openfold"
:
[
'utils/kernel/csrc/*'
],
""
:
[
"resources/stereo_chemical_props.txt"
]
},
ext_modules
=
[
CUDAExtension
(
name
=
"attn_core_inplace_cuda"
,
name
=
"attn_core_inplace_cuda"
,
sources
=
[
sources
=
[
"openfold/utils/kernel/csrc/softmax_cuda.cpp"
,
"openfold/utils/kernel/csrc/softmax_cuda.cpp"
,
...
@@ -105,7 +95,34 @@ setup(
...
@@ -105,7 +95,34 @@ setup(
extra_cuda_flags
extra_cuda_flags
),
),
}
}
)],
)]
else
:
modules
=
[
CppExtension
(
name
=
"attn_core_inplace_cuda"
,
sources
=
[
"openfold/utils/kernel/csrc/softmax_cuda.cpp"
,
"openfold/utils/kernel/csrc/softmax_cuda_stub.cpp"
,
],
extra_compile_args
=
{
'cxx'
:
[
'-O3'
],
}
)]
setup
(
name
=
'openfold'
,
version
=
'1.0.0'
,
description
=
'A PyTorch reimplementation of DeepMind
\'
s AlphaFold 2'
,
author
=
'Gustaf Ahdritz & DeepMind'
,
author_email
=
'gahdritz@gmail.com'
,
license
=
'Apache License, Version 2.0'
,
url
=
'https://github.com/aqlaboratory/openfold'
,
packages
=
find_packages
(
exclude
=
[
"tests"
,
"scripts"
]),
include_package_data
=
True
,
package_data
=
{
"openfold"
:
[
'utils/kernel/csrc/*'
],
""
:
[
"resources/stereo_chemical_props.txt"
]
},
ext_modules
=
modules
,
cmdclass
=
{
'build_ext'
:
BuildExtension
},
cmdclass
=
{
'build_ext'
:
BuildExtension
},
classifiers
=
[
classifiers
=
[
'License :: OSI Approved :: Apache Software License'
,
'License :: OSI Approved :: Apache Software License'
,
...
@@ -113,7 +130,4 @@ setup(
...
@@ -113,7 +130,4 @@ setup(
'Programming Language :: Python :: 3.7,'
'Programming Language :: Python :: 3.7,'
'Topic :: Scientific/Engineering :: Artificial Intelligence'
,
'Topic :: Scientific/Engineering :: Artificial Intelligence'
,
],
],
)
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment