首页 > 编程问答 >windows11上MMDetection 3D环境准备

windows11上MMDetection 3D环境准备

时间:2024-07-26 12:48:52浏览次数:11  
标签:python pytorch jupyter openmmlab

在使用 PyTorch 准备环境并使用 miniconda 终端安装所需的所有软件包后,在验证安装过程的最后一步中出现错误。

我创建了一个 conda 环境并激活了它, 然后我安装了 PyTorch 以及使用 MIM 所需的所有软件包。

  • MMEngine
  • MMCV
  • MMDetection
  • MMDetection3D

我还使用以下命令成功下载了配置和检查点文件;
mim download mmdet3d --config pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car --dest

但是在验证安装的最后一步我收到了错误消息。

from mmdet3d.apis import init_model, inference_detector


config_file = 'pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py'
checkpoint_file = 'hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth'
model = init_model(config_file, checkpoint_file)
inference_detector(model, 'demo/data/kitti/000008.bin')

输出

C:\Users\ANIS\miniconda3\envs\openmmlab\lib\site-packages\mmdet3d\models\dense_heads\anchor3d_head.py:92: UserWarning: dir_offset and dir_limit_offset wi 11 be depressed and be incorporated into box coder in the future
warnings.warn(
Loads checkpoint by local backend from path: hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth

错误消息 如下所示以及 jupyter 笔记本的屏幕截图中。
Traceback

AttributeError                            Traceback (most recent call last)
Cell In[1], line 5
      3 config_file = 'pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py'
      4 checkpoint_file = 'hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth'
----> 5 model = init_model(config_file, checkpoint_file)
      6 inference_detector(model, 'demo/data/kitti/000008.bin')

File ~\miniconda3/envs\openmmlab\lib\site-packages\mmdet3d\apis\inference.py:92, in init_model(config, checkpoint, device, cfg_options) 
     90 model.cfg = config  # save the config in the model for convenience
     91 if device != 'cpu':
---> 92     torch.cuda.set_device (device)
     93 else:
     94     warnings.warn('Don\'t suggest using CPU device. '
     95                   'Some functions are not supported for now.')

File ~\miniconda3/envs\openmmlab\lib\site-packages\torch\cuda\____init__.py:350, in set_device(device)
    348 device = ___get_device_index(device)
    349 if device >= 0:
--> 350     torch._C._cuda_setDevice(device)

AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'

The error message "AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'" typically arises when your PyTorch installation is not properly configured for CUDA or there's a mismatch between your PyTorch and CUDA versions.

Here's a breakdown of how to troubleshoot and resolve this issue:

1. Verify CUDA Availability and Compatibility

  • Check if CUDA is installed: Open a command prompt and run nvidia-smi . If CUDA is installed, you'll see information about your NVIDIA GPU(s). If not, download and install the appropriate CUDA toolkit for your GPU from the NVIDIA website: https://developer.nvidia.com/cuda-downloads .
  • Check CUDA version compatibility: Visit the PyTorch website ( https://pytorch.org/ ) and ensure the PyTorch version you installed supports the CUDA version on your system.

2. Reinstall PyTorch with CUDA Support

  • Uninstall existing PyTorch: bash conda activate your_environment_name conda uninstall pytorch torchvision torchaudio
  • Install PyTorch with CUDA: Replace cu117 with the CUDA version you want to use if it's different. You can find the appropriate CUDA specifier on the PyTorch website. bash conda activate your_environment_name conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch -c nvidia

3. Environment Variable Check

  • Ensure that your PATH environment variable includes the path to your CUDA installation. This is usually C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin (adjust the version number if necessary).

4. Test Your Installation

  • After reinstalling PyTorch, run a simple script to verify CUDA is working: python import torch print(torch.cuda.is_available()) # Should print True if torch.cuda.is_available(): device = torch.device('cuda') print(device) # Should print cuda:0 or similar

Additional Tips

  • Use the correct environment: Double-check that you are working within the correct conda environment where you installed MMDetection 3D and its dependencies.
  • Clean installation: If problems persist, create a fresh conda environment and reinstall all the required packages from scratch.
  • Restart: After making changes to your environment or installation, restart your Jupyter Notebook kernel or Python IDE.

By carefully following these steps, you should be able to resolve the "AttributeError" and get your MMDetection 3D environment set up correctly for GPU acceleration with CUDA.

标签:python,pytorch,jupyter,openmmlab
From: 76987253

相关文章

  • Python 教程(三):字符串特性大全
    目录专栏列表前言1.字符串基础2.字符串方法字符串查询字符串修改字符串切片3.字符串格式化旧式格式化(`%`操作符)`str.format()`方法f-string(Python3.6+)4.字符串编码5.Unicode和ASCII6.正则表达式7.字符串比较8.字符串连接9.字符串不可变性10.字符串的内......
  • python+flask计算机毕业设计新冠肺炎疫情人员统计及打卡系统(程序+开题+论文)
    本系统(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。系统程序文件列表开题报告内容研究背景自新冠肺炎疫情爆发以来,全球公共卫生体系面临前所未有的挑战。疫情防控工作的高效开展,依赖于对人员流动、健康状况及疫情数据的精准掌握与......
  • python+flask计算机毕业设计基于智能匹配的体育场馆预约系统App(程序+开题+论文)
    本系统(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。系统程序文件列表开题报告内容研究背景随着全民健身意识的日益增强,体育场馆作为民众参与体育活动的重要场所,其利用率与便捷性成为了社会关注的焦点。然而,传统的体育场馆预约方式......
  • Vonage 语音 API - 使用 python 出现错误
    我正在尝试使用vonage语音api模拟语音通话。我正在尝试使用python来做到这一点。我创建了一个.env文件并更新了应用程序id和私钥值的值,而不是路径(不确定从哪里获取它)。这是下面编写的代码:#!/usr/bin/envpython3importosfromos.pathimportjoin,dirname......
  • 数据清洗与预处理:使用 Python Pandas 库
    数据清洗与预处理:使用PythonPandas库1.简介数据清洗与预处理是数据科学和机器学习中必不可少的步骤。它涉及识别和处理原始数据中的错误、不一致和缺失值,以确保数据的质量和可靠性。Python的Pandas库提供了强大的工具,简化了数据清洗和预处理的过程。2.数据加载与探索......
  • 【Python】成功解决:`FileExistsError: [Errno 17] File exists: ‘xxx’`
    【Python】成功解决:FileExistsError:[Errno17]Fileexists:‘xxx’在Python编程中,处理文件和目录是常见的任务之一。然而,当我们尝试执行某些文件操作,如创建新文件或目录时,如果目标文件或目录已经存在,就可能会遇到FileExistsError异常。这个错误通常伴随着消息[Errno1......
  • (三)Python基本数据类型
    Python的基本数据类型包括整数类型、浮点数类型和复数类型。下面分别介绍这些数据类型以及数值运算操作符和数值运算函数。整数类型(int):整数类型表示没有小数部分的数字,可以是正数、负数或零。例如:a=5b=-3c=02.浮点数类型(float):浮点数类型表示有小数部分的数字,可以......
  • 【Python自动化办公】用Pandas库自动化操作Excel表格,从读取、写入到数据处理和分析
    文末免费赠送精品编程资料~~前言Python的第三方Pandas库是数据处理和分析中的利器,其强大的功能可以帮助我们轻松地对Excel表格进行自动化操作。接下来,我们将介绍九个用Pandas库操作Excel的编程例子,并且每个例子都会涉及不同的知识点,确保全面掌握这个主题。1.读取和写入E......
  • 总结24个Python接单赚钱平台与详细教程,兼职月入5000+
    如果说当下什么编程语言最靠谱或者比较适合搞副业?答案肯定100%是:Python。python是所有语法中最简单易上手的语言,不需要特别的的英语词汇量,逻辑思维也不需要很差就能上手。而且学会了之后就能编写代码爬取各种数据,制作各种图表,提升工作效率。而且还能利用业余时间接点私活......
  • conda 中的“torch”和“pytorch”版本不匹配
    我在环境中安装了以下内容:cudatoolkit=11.3pytorch=1.11.0torchvision=0.12.0但是当询问torch/cuda版本时,我得到了这个:$python3-c"importtorch;print(torch.__version__)"1.12.1+cu102这不是我想要的(1.12.1就可以了,但是cu102太旧了)。进一步看,我看到这......