4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

個人的な CUDA の始め方メモ

Posted at

個人的な CUDA の始め方メモ

最終的な形として
nvcc を動かす

環境

CPU : Core i3-9350KF
GPU : Quadro P400
OS : Ubuntu 18.04
nvidia-smi : 450.51.06

(検証のため i7-6700を一部使用)

簡単なインストール

まず何も入っていない状態

$ nvcc

Command 'nvcc' not found, but can be installed with:

sudo apt install nvidia-cuda-toolkit

nvidia-cuda-toolkit を入れます

$ sudo apt install nvidia-cuda-toolkit
$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

入ったのは cuda9.1 の模様

main.cu
#include <stdio.h>

__global__ void hello() {
	printf("Hoge\n");
}

int main() {
	hello<<<1,1>>>();
	cudaDeviceSynchronize();
}
$ nvcc main.cu
$ ./a.out
Hoge

とりあえず動確

CUDA 11.0

###どうにかして CUDA 11.0 を入手しておく
どういうわけかメインマシンには入っていたので割愛
nvidia-smi 入れるときとか
ubuntu-drivers autoinstall とか
ffmpeg とか入れるときに何かしたかも

CUDA 11.0 の導入が住んでいるかの確認

$ ls /usr/local/ |grep cuda
cuda
cuda-10.2
cuda-11.0

CUDA 11.0 への以降(自己責任で)

$ which nvcc
/usr/bin/nvcc

sudo cp /usr/local/cuda-11.0/bin/nvcc /usr/bin/nvcc

上書きするぞ

パスを通す

export PATH="/usr/local/cuda/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"

.bashrc に上記を記述 &source

nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Thu_Jun_11_22:26:38_PDT_2020
Cuda compilation tools, release 11.0, V11.0.194
Build cuda_11.0_bu.TC445_37.28540450_0

CUDA 11 になってる

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?