学过的知识

学过的知识

我正在尝试在我的 Ubuntu 16.04 LTS 上安装 NVIDIA CUDA 8.0,即使遵循Linux安装指南来自 NVIDIA 我无法让它工作。

以下是详细信息。

我有一台 Acer Aspire VX 笔记本电脑,它预装了 Windows 10,我安装了 Ubuntu 的双启动。硬件是 Intel Core i5 7300HQ 和 NVIDIA GeForce 1050。

安装前的操作及其输出:

$ lspci | grep -i nvidia
01:00.0 3D controller: NVIDIA Corporation Device 1c8d (rev a1)


$ uname -m && cat /etc/*release
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
NAME="Ubuntu"
VERSION="16.04.3 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.3 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial


$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -r
4.10.0-33-generic

到这里一切都很好。此外,我按照指导。我下载了文件.deb来自 NVIDIA 网站,适用于 Linux x86_64 机器。

  1. $ sudo dpkg -i /home/marlosdamasceno/Downloads/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
  2. $ sudo apt-get 更新
  3. $ sudo apt-get 安装 cuda

这也很好。在我安装了补丁 2(2017 年 6 月 26 日发布)。步骤如下。

  1. $ sudo dpkg -i /home/marlosdamasceno/Downloads/cuda-repo-ubuntu1604-8-0-local-cublas-performance-update_8.0.61-1_amd64.deb
  2. $ sudo apt-get 更新
  3. $ sudo apt-get 升级 cuda

到这里一切看起来都还好。因此,我按照安装后的操作进行操作。

$ export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61

$ cuda-install-samples-8.0.sh /home/marlosdamasceno/

好的,一切看起来又正常了,但是这是第一个问题,当我检查驱动程序时,根本没有nvidia的文件夹。

$ cat /proc/driver/nvidia/version

cat:/proc/driver/nvidia/version:没有此文件或目录

这是该文件夹的打印件:https://ibb.co/cWjpTa

文件夹中唯一的东西是一个 rtc 文件。

我尝试继续前进,并做到了制作样本步骤。我得到了这个:

/usr/bin/ld: cannot find -lnvcuvid
collect2: error: ld returned 1 exit status
Makefile:381: recipe for target 'cudaDecodeGL' failed
make[1]: *** [cudaDecodeGL] Error 1
make[1]: Leaving directory '/home/marlosdamasceno/NVIDIA_CUDA-8.0_Samples/3_Imaging/cudaDecodeGL'
Makefile:52: recipe for target '3_Imaging/cudaDecodeGL/Makefile.ph_build' failed
make: *** [3_Imaging/cudaDecodeGL/Makefile.ph_build] Error 2

此外,当我运行设备查询,我收到了这条消息。

./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 35
-> CUDA driver version is insufficient for CUDA runtime version
Result = FAIL

此外,这里还有一些命令和输出可以提供帮助。

键入此命令时什么也没有发生。

$ lsmod | grep nvidia

另一个命令。

$ nvidia-smi
nvidia-smi: command not found

另一个命令。

$ sudo lshw -c video
*-display               
       description: 3D controller
       product: NVIDIA Corporation
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: driver=nouveau latency=0
       resources: irq:318 memory:a3000000-a3ffffff memory:90000000-9fffffff memory:a0000000-a1ffffff ioport:4000(size=128)
  *-display
       description: VGA compatible controller
       product: Intel Corporation
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 04
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:319 memory:a2000000-a2ffffff memory:b0000000-bfffffff ioport:5000(size=64) memory:c0000-dffff

问题如下。

我有安全启动启用,有可能吗?

命令中的路径文件导出 PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}总是会自行删除。所以当我执行命令时$ nvcc——版本,我收到消息了。

The program 'nvcc' is currently not installed. You can install it by typing: sudo apt install nvidia-cuda-toolkit 

我该如何设置路径并保持其不变?

我是否遗漏了某一步骤?

提前感谢任何帮助!!!

答案1

经过为 Ubuntu 新手付出大量努力之后,我终于让它工作了!!!

@ubfan1当他说出命令时帮助了我,lshw -c video提示我需要知道我没有在 NVIDIA 的驱动程序上运行时。

之后我尝试安装但没有成功(安全启动已关闭)。我收到此错误:“系统正在低图形模式下运行”(看到这个问题)。因此,我使用命令**Alt+Ctrl+F1*进行启动,并使用以下命令从 NVIDIA 中删除所有文件。

sudo apt-get remove --purge nvidia-*

这样我就可以回到我的桌面,在那里我可以使用系统设置Ubuntu 中的工具来安装驱动程序(软件和更新 -> 附加驱动程序 -> 使用 NVIDIA 二进制文件 - 版本 375.82(来自 nvidia-375 )(开源). 查看印刷品:

NVIDIA 驱动程序

我重启了系统,一切都安装好了!之后我测试了命令./设备查询从垃圾桶里面取出样品,测试PASS!

./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 1050"
  CUDA Driver Version / Runtime Version          8.0 / 8.0
  CUDA Capability Major/Minor version number:    6.1
  Total amount of global memory:                 4041 MBytes (4237426688 bytes)
  ( 5) Multiprocessors, (128) CUDA Cores/MP:     640 CUDA Cores
  GPU Max Clock rate:                            1493 MHz (1.49 GHz)
  Memory Clock rate:                             3504 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 524288 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 2 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GTX 1050
Result = PASS

学过的知识

在安装 CUDA 之前,请确保 NVIDIA 的所有驱动程序都运行正常!您可以像下面这样安装它们@ubfan1在此建议关联

执行以下命令检查安装是否是默认安装并且正在运行。

$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  375.82  Wed Jul 19 21:16:49 PDT 2017
GCC version:  gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)

$ sudo lshw -c video
[sudo] password for marlosdamasceno: 
  *-display               
       description: 3D controller
       product: NVIDIA Corporation
       vendor: NVIDIA Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: driver=nvidia latency=0
       resources: irq:321 memory:a3000000-a3ffffff memory:90000000-9fffffff memory:a0000000-a1ffffff ioport:4000(size=128)
  *-display
       description: VGA compatible controller
       product: Intel Corporation
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 04
       width: 64 bits
       clock: 33MHz
       capabilities: pciexpress msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:318 memory:a2000000-a2ffffff memory:b0000000-bfffffff ioport:5000(size=64) memory:c0000-dffff

$ lsmod | grep nvidia
nvidia_uvm            647168  0
nvidia_drm             45056  2
nvidia_modeset        790528  5 nvidia_drm
nvidia              12701696  85 nvidia_modeset,nvidia_uvm
drm_kms_helper        151552  2 i915,nvidia_drm
drm                   352256  6 i915,nvidia_drm,drm_kms_helper


$ nvidia-smi
Fri Sep  8 19:47:17 2017       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.82                 Driver Version: 375.82                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1050    Off  | 0000:01:00.0     Off |                  N/A |
| N/A   49C    P0    N/A /  N/A |    536MiB /  4041MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0       996    G   /usr/lib/xorg/Xorg                             271MiB |
|    0      1827    G   compiz                                         177MiB |
|    0      2351    G   ...el-token=FDDD25D3486FDA0AB5CD0952493279C6    86MiB |
|    0     14381    G   unity-control-center                             1MiB |
+-----------------------------------------------------------------------------+

只需检查一下安全启动就可以运行。

$ mokutil --sb-state
SecureBoot enabled

答案2

永久设置路径:

$ gedit ~/.bashrc

文件将加载。在该文件中,转到底部并粘贴以下内容:

导出 PATH=/usr/local/cuda-8.0/bin:$PATH

保存并关闭。

相关内容