简体   繁体   English

在 Ubuntu18.04 中使用 CUDA 使用 Python 库 Keops 的运行时错误

[英]Runtime error using Python Library Keops using CUDA in Ubuntu18.04

I am trying to run samples from the Python library: GeomLoss , which depends on CUDA, Pytorch and Keops in Ubuntu 18.04.3.我试图从Python库运行样品: GeomLoss ,这取决于CUDA,Pytorch和KEOPS在Ubuntu 18.04.3。 I downloaded Python3.7 using Anaconda, and I am using CUDA 10.1.我使用 Anaconda 下载了 Python3.7,我使用的是 CUDA 10.1。 The gcc version is 7.4.0. gcc 版本是 7.4.0。

When I run samples from GeomLoss, the error message said:当我从 GeomLoss 运行样本时,错误消息说:

RuntimeError: [KeOps] This KeOps shared object has been compiled without cuda support: try to set tagHostDevice to 0 or recompile the formula with a working version of cuda. RuntimeError: [KeOps] 此 KeOps 共享对象已在没有 cuda 支持的情况下编译:尝试将 tagHostDevice 设置为 0 或使用 cuda 的工作版本重新编译公式。

I cannot change tagHostDevice to 0 since this will disable GPU calculation according to their documentation.我无法将 tagHostDevice 更改为 0,因为这将根据他们的文档禁用 GPU 计算。 I checked CUDA and Pytorch installation and they was no error.我检查了 CUDA 和 Pytorch 安装,它们没有错误。 But when I tried to run the installation checking code from KeOps:但是当我尝试从 KeOps 运行安装检查代码时:

import torch
import pykeops.torch as pktorch

x = torch.arange(1, 10, dtype=torch.float32).view(-1, 3)
y = torch.arange(3, 9, dtype=torch.float32).view(-1, 3)

my_conv = pktorch.Genred('SqNorm2(x-y)', ['x = Vi(3)', 'y = Vj(3)'])
print(my_conv(x, y)) 

I received error message:我收到错误消息:

error -- unsupported GNU version!错误 - 不受支持的 GNU 版本! gcc versions later than 6 are not supported!不支持 6 之后的 gcc 版本! ^~~~~ CMake Error at keopslibKeOpstorch91c92bd508_generated_link_autodiff.cu.o.Release.cmake:219 ^~~~~ keopslibKeOpstorch91c92bd508_generated_link_autodiff.cu.o.Release.cmake:219 处的 CMake 错误

I checked CUDA documentation, for Ubuntu 18.04.3, the native linux distribution support should be gcc-7.3.0.我查看了 CUDA 文档,对于 Ubuntu 18.04.3,本机 linux 发行版支持应该是 gcc-7.3.0。 for x86_64.对于 x86_64。 I used gcc --version to check default gcc in system and it is using gcc-7.4.0.我使用gcc --version来检查系统中的默认 gcc,它使用的是 gcc-7.4.0。 I am not sure if this is the problem with using KeOps with CUDA and GPU.我不确定这是否是将 KeOps 与 CUDA 和 GPU 结合使用的问题。 Also, I believe KeOps will not support gcc versions before 7. So I am really confused about what should I do to fix the problem right now.另外,我相信 KeOps 不会支持 7 之前的 gcc 版本。所以我真的很困惑我现在应该怎么做才能解决这个问题。

I am wondering if anyone has experienced similar problems with GeomLoss and KeOps or other libraries.我想知道是否有人在使用 GeomLoss 和 KeOps 或其他库时遇到过类似的问题。 I am indeed grateful for any suggestions.我真的很感激任何建议。 Thanks!谢谢!

I did the following steps and it worked for me:我做了以下步骤,它对我有用:

First, by checking the dependencies in this link I noticed that nvcc compiler is not installed.首先,通过检查此 链接中的依赖项,我注意到未安装nvcc编译器。 By going to Nvidia Toolkit Installation Guide I did the following steps:通过转到Nvidia Toolkit 安装指南,我执行了以下步骤:

wget https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda_11.2.2_460.32.03_linux.run
sudo sh cuda_11.2.2_460.32.03_linux.run

Then I realized that nvcc command not working, so I did add them to the path using:然后我意识到nvcc命令不起作用,所以我确实使用以下方法将它们添加到路径中:

nano ~/.bashrc

# Add the following two lines: 
export PATH="$PATH:/usr/local/cuda/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"

In general, it is important to see the logs of PyKeops to check the process.一般来说,查看PyKeops的日志来检查进程很重要。 So, you can always change the verbose and debug mode and see the details to check out what failed:因此,您可以随时更改verbosedebug模式并查看详细信息以检查失败的原因:

# Testing PyKeops installation
import pykeops

# Changing verbose and mode
pykeops.verbose = True
pykeops.build_type = 'Debug'

# Clean up the already compiled files
pykeops.clean_pykeops()

# Test Numpy integration
pykeops.test_numpy_bindings()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM