aqlaboratory / openfold

Trainable, memory-efficient, and GPU-friendly PyTorch reproduction of AlphaFold 2
Apache License 2.0
2.83k stars 551 forks source link

RuntimeError: Error compiling objects for extension #227

Open liweiqing1997 opened 2 years ago

liweiqing1997 commented 2 years ago

Please help me. How to solve this problem. I have no idea::::

/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:57:59: 错误:从类型‘const torch::OrderedDict<std::basic_string, at::Tensor>’到类型‘torch::OrderedDict<std::basic_string, at::Tensor>&’中的 static_cast 无效 /data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:69:61: 错误:从类型‘const torch::OrderedDict<std::basic_string, std::shared_ptr >’到类型‘torch::OrderedDict<std::basic_string, std::shared_ptr >&’中的 static_cast 无效 /data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h: In instantiation of ‘std::shared_ptr torch::nn::Cloneable::clone(const c10::optional&) const [with Derived = torch::nn::UnflattenImpl]’: /data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/optim/sgd.h:49:48: required from here /data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:57:59: 错误:从类型‘const torch::OrderedDict<std::basic_string, at::Tensor>’到类型‘torch::OrderedDict<std::basic_string, at::Tensor>&’中的 static_cast 无效 /data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:69:61: 错误:从类型‘const torch::OrderedDict<std::basic_string, std::shared_ptr >’到类型‘torch::OrderedDict<std::basic_string, std::shared_ptr >&’中的 static_cast 无效 /data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h: In instantiation of ‘std::shared_ptr torch::nn::Cloneable::clone(const c10::optional&) const [with Derived = torch::nn::LinearImpl]’: /data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/optim/sgd.h:49:48: required from here /data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:57:59: 错误:从类型‘const torch::OrderedDict<std::basic_string, at::Tensor>’到类型‘torch::OrderedDict<std::basic_string, at::Tensor>&’中的 static_cast 无效 /data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:69:61: 错误:从类型‘const torch::OrderedDict<std::basic_string, std::shared_ptr >’到类型‘torch::OrderedDict<std::basic_string, std::shared_ptr >&’中的 static_cast 无效 ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1814, in _run_ninja_build env=env) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/subprocess.py", line 512, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "setup.py", line 95, in 'Programming Language :: Python :: 3.7,' File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/setuptools/init.py", line 153, in setup return distutils.core.setup(**attrs) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/core.py", line 148, in setup dist.run_commands() File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/setuptools/command/install.py", line 74, in run self.do_egg_install() File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/setuptools/command/install.py", line 116, in do_egg_install self.run_command('bdist_egg') File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 164, in run cmd = self.call_command('install_lib', warn_dir=0) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 150, in call_command self.run_command(cmdname) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/setuptools/command/install_lib.py", line 11, in run self.build() File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/command/install_lib.py", line 107, in build self.run_command('build_ext') File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 79, in run _build_ext.run(self) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/command/build_ext.py", line 340, in run self.build_extensions() File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 765, in build_extensions build_ext.build_extensions(self) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions self._build_extensions_serial() File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial self.build_extension(ext) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 202, in build_extension _build_ext.build_extension(self, ext) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/distutils/command/build_ext.py", line 534, in build_extension depends=ext.depends) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 595, in unix_wrap_ninja_compile with_cuda=with_cuda) File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1492, in _write_ninja_file_and_compile_objects error_prefix='Error compiling objects for extension') File "/data/lwq/openfold-main/lib/conda/envs/openfold_venv/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1824, in _run_ninja_build raise RuntimeError(message) from e RuntimeError: Error compiling objects for extension

gahdritz commented 2 years ago

Do you have gcc and nvcc on your PATH? You need both in order to run setup.py and train the model. On many systems, you can just run module load cuda cudnn gcc before using OpenFold to clear up all issues of this kind.

liweiqing1997 commented 2 years ago

Do you have gcc and nvcc on your PATH? You need both in order to run setup.py and train the model. On many systems, you can just run module load cuda cudnn gcc before using OpenFold to clear up all issues of this kind.

yes,i have. I solved it like this, I don't know if there will be side effects: Change the line "cmdclass={'build_ext': BuildExtension}" in setup.py to "cmdclass={'build_ext': BuildExtension.with_options(use_ninja=False)}"