问题1:TypeError: new() missing 1 required positional argument: ‘is_raw’
Traceback (most recent call last):
File "Dicom_2_Png.py", line 75, in <module>
slices = load_patient(dicom_dir)
File "Dicom_2_Png.py", line 37, in load_patient
instance = pydicom.dcmread(src_dir + '/' + s)
File "/home/USER/anaconda2/envs/Pulmonary-Nodule-Detection-Based-on-Deep-Learning/lib/python3.6/site-packages/pydicom/filereader.py", line 888, in dcmread
force=force, specific_tags=specific_tags)
File "/home/USER/anaconda2/envs/Pulmonary-Nodule-Detection-Based-on-Deep-Learning/lib/python3.6/site-packages/pydicom/filereader.py", line 672, in read_partial
file_meta_dataset = _read_file_meta_info(fileobj)
File "/home/USER/anaconda2/envs/Pulmonary-Nodule-Detection-Based-on-Deep-Learning/lib/python3.6/site-packages/pydicom/filereader.py", line 524, in _read_file_meta_info
stop_when=_not_group_0002
File "/home/USER/anaconda2/envs/Pulmonary-Nodule-Detection-Based-on-Deep-Learning/lib/python3.6/site-packages/pydicom/filereader.py", line 359, in read_dataset
raw_data_element = next(de_gen)
File "/home/USER/anaconda2/envs/Pulmonary-Nodule-Detection-Based-on-Deep-Learning/lib/python3.6/site-packages/pydicom/filereader.py", line 206, in data_element_generator
is_implicit_VR, is_little_endian)
TypeError: __new__() missing 1 required positional argument: 'is_raw'
最好的解决方式(亲测有用):
我的服务器上的conda环境下的python版本是3.6.0,更换为3.6.1就成功解决了问题。
问题2:ImportError: /data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/torch/lib/libtorch_python.so: undefined symbol: PySlice_Unpack
Traceback (most recent call last):
File "run.py", line 3, in <module>
from simclr import SimCLR
File "/data/Project/luanhaijing/MSI-MIL/extract_simCLR_feature/simclr/simclr.py", line 3, in <module>
import torch
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/torch/__init__.py", line 189, in <module>
from torch._C import *
ImportError: /data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/torch/lib/libtorch_python.so: undefined symbol: PySlice_Unpack
解决方法:将python版本更新到3.6.2
问题3:No module named ‘tensorboard’
解决方案:pip install tensorboard
问题4:No module named ‘yaml’
解决方案:pip install pyyaml
问题4:opencv-python的安装问题,最好参考链接(python与opencv版本的对应关系来进行库的安装)
(simclr) [luanhaijing@gpu02 simclr]$ python3 -m pip install opencv-python
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting opencv-python
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/fa/1d/990ad4eb4d385fabb2773170cf865977b6d5b558dd51459672f7cf7d1847/opencv-python-4.8.0.74.tar.gz (92.1 MB)
ERROR: Error expected str, bytes or os.PathLike object, not NoneType while executing command /data/luanhaijing/software/anaconda3/envs/simclr/bin/python3 /data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-ig5gmi02/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host https --trusted-host '' --trusted-host trusted-host -- 'cmake>=3.1' 'numpy==1.13.3; python_version=='"'"'3.6'"'"' and platform_machine != '"'"'aarch64'"'"' and platform_machine != '"'"'arm64'"'"'' 'numpy==1.17.0; python_version=='"'"'3.7'"'"' and platform_machine != '"'"'aarch64'"'"' and platform_machine != '"'"'arm64'"'"'' 'numpy==1.17.5; python_version=='"'"'3.8'"'"' and platform_machine != '"'"'aarch64'"'"' and platform_machine != '"'"'arm64'"'"'' 'numpy==1.19.3; python_version<='"'"'3.9'"'"' and sys_platform == '"'"'linux'"'"' and platform_machine == '"'"'aarch64'"'"'' 'numpy==1.21.0; python_version<='"'"'3.9'"'"' and sys_platform == '"'"'darwin'"'"' and platform_machine == '"'"'arm64'"'"'' 'numpy==1.19.3; python_version=='"'"'3.9'"'"' and platform_machine != '"'"'aarch64'"'"' and platform_machine != '"'"'arm64'"'"'' 'numpy==1.21.2; python_version=='"'"'3.10'"'"' and platform_system!='"'"'Darwin'"'"'' 'numpy==1.21.4; python_version=='"'"'3.10'"'"' and platform_system=='"'"'Darwin'"'"'' 'numpy==1.22.2; python_version>='"'"'3.11'"'"'' pip 'scikit-build>=0.14.0' setuptools==59.2.0
Installing build dependencies ... error
ERROR: Exception:
Traceback (most recent call last):
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 186, in _main
status = self.run(options, args)
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 331, in run
resolver.resolve(requirement_set)
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 282, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 516, in prepare_linked_requirement
req, self.req_tracker, self.finder, self.build_isolation,
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 95, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/distributions/sdist.py", line 38, in prepare_distribution_metadata
self._setup_isolation(finder)
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/distributions/sdist.py", line 68, in _setup_isolation
"Installing build dependencies"
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/build_env.py", line 201, in install_requirements
call_subprocess(args, spinner=spinner)
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/pip/_internal/utils/subprocess.py", line 190, in call_subprocess
stdout=subprocess.PIPE, cwd=cwd, env=env,
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/subprocess.py", line 1267, in _execute_child
restore_signals, start_new_session, preexec_fn)
TypeError: expected str, bytes or os.PathLike object, not NoneType
问题5:No module named ‘skimage‘
解决办法:pip install scikit-image
问题6:模型的cuda版本与显卡版本之间的关系:
Please install apex for mixed precision training from: https://github.com/NVIDIA/apex
Running on: cuda
/data/luanhaijing/software/anaconda3/envs/simclr/lib/python3.6/site-packages/torch/cuda/__init__.py:125: UserWarning:
NVIDIA A800 80GB PCIe with CUDA capability sm_80 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_61 sm_70 sm_75 compute_37.
If you want to use the NVIDIA A800 80GB PCIe GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
问题6:AttributeError: module ‘numpy’ has no attribute ‘object’.
np.object
was a deprecated alias for the builtin object
. To avoid this error in existing code, use object
by itself. Doing this will not modify any behavior and is safe.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
解决方法:pip install numpy==1.19.5
问题7:-bash: git: command not found
解决方法:conda install git
问题8:如何安装apex
错误1:
(msi-mil) [luanhaijing@gpu02 apex]$ python setup.py install --cuda_ext
torch.__version__ = 2.0.1
Traceback (most recent call last):
File "/data/Project/luanhaijing/MSI-MIL/extract_swav_feature/apex/setup.py", line 137, in <module>
_, bare_metal_version = get_cuda_bare_metal_version(CUDA_HOME)
File "/data/Project/luanhaijing/MSI-MIL/extract_swav_feature/apex/setup.py", line 24, in get_cuda_bare_metal_version
raw_output = subprocess.check_output([cuda_dir + "/bin/nvcc", "-V"], universal_newlines=True)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
解决方案: conda install -c nvidia cuda-nvcc
错误2:通过python setup.py install --cuda_ext
命令进行apex的安装时,报错:
(SwAV) [luanhaijing@gpu02 apex]$ python setup.py install --cuda_ext
torch.__version__ = 1.4.0
Compiling cuda extensions with
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Jul_11_02:20:44_PDT_2023
Cuda compilation tools, release 12.2, V12.2.128
Build cuda_12.2.r12.2/compiler.33053471_0
from /data/luanhaijing/software/anaconda3/envs/SwAV/bin
Traceback (most recent call last):
File "setup.py", line 178, in <module>
check_cuda_torch_binary_vs_bare_metal(CUDA_HOME)
File "setup.py", line 44, in check_cuda_torch_binary_vs_bare_metal
+ "In some cases, a minor-version mismatch will not cause later errors: "
RuntimeError: Cuda extensions are being compiled with a version of Cuda that does not match the version used to compile Pytorch binaries. Pytorch binaries were compiled with Cuda 10.1.
In some cases, a minor-version mismatch will not cause later errors: https://github.com/NVIDIA/apex/pull/323#discussion_r287021798. You can try commenting out this check (at your own risk).
根据错误的提醒,需要查看这个链接中所对应的处理https://github.com/NVIDIA/apex/pull/323#discussion_r287021798,具体的处理方案为,更换运行命令后,成功解决了我的问题:python setup.py install
问题9:在使用conda来进行包的安装时会出现错误提示。
(SWAV) [luanhaijing@gpu02 apex]$ conda install pytorch==1.9.0 torchvision==0.10.0 cudatoolkit=11.1 -c pytorch -n SWAV
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- cudatoolkit=11.1
Current channels:
- https://conda.anaconda.org/pytorch/linux-64
- https://conda.anaconda.org/pytorch/noarch
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
解决放在在错误提示中,具体详见该博客参考,并且使用该命令完成了安装工作: conda install -c dglteam dgl-cuda11.1
问题10:
错误:RuntimeError: NCCL error in: /pytorch/torch/lib/c10d/ProcessGroupNCCL.cpp:31, unhandled cuda error, NCCL version 2.7.8 work = _default_pg.barrier() RuntimeError: NCCL error in: /pytorch/torch/lib/c10d/ProcessGroupNCCL.cpp:31, unhandled cuda error, NCCL version 2.7.8
,解决方法pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
,详见参考链接