Przejdź do zawartości

Programowanie w systemie UNIX/CUDA

Z Wikibooks, biblioteki wolnych podręczników.
Porównanie wydajności CPU i GPU


Informacja
Książka wymaga poprawek: nie można zainstalować CUDA !!!


Wstęp do CUDA [1]

Instalacja

[edytuj]

Opis[2][3][4] [5][6]

sudo dpkg --install cuda-repo-<distro>-<version>.<architecture>.deb
sudo apt-key del 7fa2af80
wget https://developer.download.nvidia.com/compute/cuda/repos/$distro/$arch/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo add-apt-repository contrib
sudo apt-get update
sudo apt-get -y install cuda
sudo reboot
export PATH=/usr/local/cuda-12.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.2/lib64 ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
git clone git@github.com:NVIDIA/cuda-samples.git


Instalacja

sprzęt

[edytuj]

Sprawdzamy jaką mamy kartę graficzną:[8]

lspci | grep -i nvidia

lub za pomocą komendy:

lspci | grep VGA
lshw -c video | grep driver
ubuntu-drivers devices


lub[9]

 nvidia-smi 


i czy jest ona na liście kompatybilnego sprzętu: [10]

https://developer.nvidia.com/cuda-gpus

Nvidia GTX 770

[edytuj]
The GeForce GTX 770 is a graphics card featuring the next-gen Kepler-based GPU with 1536 CUDA cores, It features an amazing GDDR5 memory at 7GHz. It sports a pair of SLI connectors, 6-pin and 8-pin PCIe power connectors, and an I/O panel consisting of HDMI, DisplayPort and two DVI ports. The GTX 770 packs 4 graphics processing clusters, 8 streaming multiprocessors, 128 TAUs and 32 ROPs.[11]

Specyfikacja:

  • GTX 770 GPU Engine Specs:
 1536CUDA Cores
 1046Base Clock (MHz)
 1085Boost Clock (MHz)
 134Texture Fill Rate (billion/sec)

GTX 770 Memory Specs:

 7.0 GbpsMemory Speed
 2048 MBStandard Memory Config
 GDDR5Memory Interface
 256-bitMemory Interface Width
 224.3Memory Bandwidth (GB/sec)

GTX 770 Support:

 GPU Boost 2.0, PhysX, TXAA, SHIELD-Ready, NVIDIA G-SYNC-readyImportant Technologies
 3D Vision, CUDA, DirectX 11, Adaptive VSync, FXAA,
 NVIDIA Surround, SLI-readyOther Supported Technologies
 4.3OpenGL
 PCI Express 3.0Bus Support
 YesCertified for Windows 7, Windows 8, Windows Vista, or Windows XP
 Yes3D Vision Ready
 Yes3D Gaming
 YesBlu Ray 3D
 Yes3D Vision Live (Photos and Videos)
 YesNVIDIA PhysX™ Technology
 11Microsoft DirectX 11.2 API

Display Support:

 4096x2160Maximum Digital Resolution 1
 2048x1536Maximum VGA Resolution
 One Dual Link DVI-I, One Dual Link DVI-D, One HDMI, One DisplayPortStandard Display Connectors
 4 displaysMulti Monitor
 YesHDCP
 YesHDMI
 InternalAudio Input for HDMI

GTX 770 Graphics Card Dimensions:

 4.376 inchesHeight
 10.5 inchesLength
 Dual-slotWidth

Thermal and Power Specs:

 98 CMaximum GPU Temperature (in C)
 230 WGraphics Card Power (W)
 600 WMinimum Recommended System Power (W)
 One 8-pin and one 6-pinSupplementary Power Connectors

1 - 3840x2160 at 30Hz or 4096x2160 at 24Hz supported over HDMI. 4096x2160 (including 3840x2160) at 60Hz supported over Displayport. Support for 4k tiled MST displays requires 326.19 driver or later.


Graphics Features[12]

  • DirectX 12 (11_0)
  • OpenGL 4.6
  • OpenCL 3.0
  • Vulkan 1.2.175
  • CUDA 3.0
  • Shader Model 6.5 (5.1)

Render Config

  • Shading Units 1536
  • TMUs 128 ( texture mapping units)
  • ROPs 32
  • SMX Count 8 ( The Next Generation Streaming Multiprocessor SMX)
  • L1 Cache 16 KB (per SMX)
  • L2 Cache 512 KB

Graphics Processor

  • GPU Name GK104
  • GPU Variant GK104-425-A2
  • Architecture Kepler
  • Foundry TSMC
  • Process Size 28 nm
  • Transistors 3,540 million
  • Density 12.0M / mm²
  • Die Size 294 mm²
  • Chip Package BGA-1745
  • the SMX now contains 196 cores
  • 8 SMX * 196 cores = 1536 cores to reach 3,250 Gflops


Theoretical Performance

  • Pixel Rate 34.72 GPixel/s
  • Texture Rate 138.9 GTexel/s
  • FP32 (float) 3.333 TFLOPS
  • FP64 (double) 138.9 GFLOPS (1:24)

OS

[edytuj]

Wybieramy taką wersję OS dla której jest dostępny CUDA Toolkit[13]


Sprawdzamy aktualną wersję i typ OS:

uname -m && cat /etc/*release

otrzymujemy (przykładowy wynik):

x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.10
DISTRIB_CODENAME=saucy
DISTRIB_DESCRIPTION="Ubuntu 13.10"
NAME="Ubuntu"
VERSION="13.10, Saucy Salamander"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 13.10"
VERSION_ID="13.10"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"


Informacje o instalacji dla wersji:

cuda-drivers

[edytuj]
 apt search cuda-drivers #  This command lists all the available CUDA versions



Sorting... Done
Full Text Search... Done
cuda-drivers/unknown 535.86.10-1 amd64
  CUDA Driver meta-package, branch-agnostic

cuda-drivers-515/unknown 515.105.01-1 amd64
  CUDA Driver meta-package, branch-specific

cuda-drivers-520/unknown 520.61.05-1 amd64
  CUDA Driver meta-package, branch-specific

cuda-drivers-525/unknown 525.125.06-1 amd64
  CUDA Driver meta-package, branch-specific

cuda-drivers-530/unknown 530.30.02-1 amd64
  CUDA Driver meta-package, branch-specific

cuda-drivers-535/unknown 535.86.10-1 amd64
  CUDA Driver meta-package, branch-specific

cuda-drivers-fabricmanager/unknown 535.86.10-1 amd64
  Meta-package for FM and Driver

cuda-drivers-fabricmanager-450/jammy-updates,jammy-security 450.248.02-0ubuntu0.22.04.1 amd64
  Meta-package for FM and Driver

cuda-drivers-fabricmanager-460/jammy-updates,jammy-security 510.85.02-0ubuntu0.22.04.1 amd64
  Transitional package for cuda-drivers-fabricmanager-510

cuda-drivers-fabricmanager-470/jammy-updates,jammy-security 470.199.02-0ubuntu0.22.04.1 amd64
  Meta-package for FM and Driver

cuda-drivers-fabricmanager-510/jammy-updates,jammy-security 515.105.01-0ubuntu0.22.04.1 amd64
  Transitional package for cuda-drivers-fabricmanager-515

cuda-drivers-fabricmanager-515/unknown 515.105.01-1 amd64
  Meta-package for FM and Driver

cuda-drivers-fabricmanager-520/unknown 520.61.05-1 amd64
  Meta-package for FM and Driver

cuda-drivers-fabricmanager-525/unknown 525.125.06-1 amd64
  Meta-package for FM and Driver

cuda-drivers-fabricmanager-530/unknown 530.30.02-1 amd64
  Meta-package for FM and Driver

cuda-drivers-fabricmanager-535/unknown 535.86.10-1 amd64
  Meta-package for FM and Driver


Sterownik karty graficznej

[edytuj]

Sterownik [19]

sudo software-properties-gtk

lub:

nvidia-settings

lub

apt list --installed | grep -e nvidia-driver-[0-9][0-9][0-9] -e nvidia-[0-9][0-9][0-9]


Rekomendowany sterownik:

 ubuntu-drivers devices


Przykładowy wynik:

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001184sv00001458sd00003603bc03sc00i00
vendor   : NVIDIA Corporation
model    : GK104 [GeForce GTX 770]
driver   : nvidia-driver-450-server - distro non-free
driver   : nvidia-driver-390 - distro non-free
driver   : nvidia-driver-418-server - distro non-free
driver   : nvidia-driver-470 - distro non-free recommended
driver   : nvidia-driver-470-server - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

Aktualny sterownik:

nvidia-smi

gcc

[edytuj]

Czy mamy odpowiednią[20] wersję gcc ?


        _______________________________________________________________
	|           CUDA version          | max supported GCC version |
	|:-------------------------------:|:-------------------------:|
	|            12.1, 12.2           |           12.2            |
	|                12               |           12.1            |
        | 11.4.1+, 11.5, 11.6, 11.7, 11.8 |            11             |
	|     11.1, 11.2, 11.3, 11.4.0    |            10             |
	|                11               |             9             |
	|            10.1, 10.2           |             8             |
	|             9.2, 10.0           |             7             |
	|             9.0, 9.1            |             6             |
	|                8                |            5.3            |
	|                7                |            4.9            |
	|              5.5, 6             |            4.8            |
	|              4.2, 5             |            4.6            |
	|               4.1               |            4.5            |
	|               4.0               |            4.4            |
        ____________________________________________________________



Sprawdzamy wersję gcc

gcc --version
apt policy gcc
gcc:
 Installed: 4:11.2.0-1ubuntu1
 Candidate: 4:11.2.0-1ubuntu1
 Version table:
*** 4:11.2.0-1ubuntu1 500
       500 http://pl.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
       100 /var/lib/dpkg/status




W przeciwnym razie pojawi się błąd w czasie instalacji :

 Error: unsupported compiler: 5.4.1. Use --override to override this check.


Rozwiązanie[21] :

  • sudo sh cuda_8.0.44_linux.run --override


lina 81:/usr/local/cuda/include/host_config.h

//#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)

Wybieramy odpowiednią wersję gcc za pomocą update-alternatives

sudo update-alternatives --config gcc


sudo gedit /var/log/cuda-installer.log 
[INFO]: Driver installation detected by command: apt list --installed | grep -e nvidia-driver-[0-9][0-9][0-9] -e nvidia-[0-9][0-9][0-9]
[INFO]: Cleaning up window
[INFO]: Complete
[INFO]: Checking compiler version...
[INFO]: gcc location: /usr/bin/gcc

[INFO]: gcc version: gcc version 10.4.0 (Ubuntu 10.4.0-4ubuntu1~22.04) 

[INFO]: Initializing menu
[INFO]: Setup complete
[INFO]: Components to install: 
[INFO]: Driver
[INFO]: 470.42.01
[INFO]: Executing NVIDIA-Linux-x86_64-470.42.01.run --ui=none --no-questions --accept-license --disable-nouveau --no-cc-version-check --install-libglvnd  2>&1
[INFO]: Finished with code: 256
[ERROR]: Install of driver component failed.
[ERROR]: Install of 470.42.01 failed, quitting

SDK = NVIDIA CUDA Toolkit

[edytuj]

Nvidia CUDA toolkit[22]

 dpkg -l | grep cuda-toolkit

lub

 nvcc --version


Instalacja

  • apt
  • instaler runfile

Instalacja:

  • na pulpicie naciśnij ALT+F1, spowoduje to przejście do ekranu konsoli
  • zaloguj się jako root( tylko root może instalować moduły jądra)
  • sudo systemctl isolate multi-user.target
  • run the nVidia install script
  • reboot
wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run
sudo sh cuda_11.4.0_470.42.01_linux.run


sudo /usr/local/cuda-10.1/bin/cuda-uninstaller
sudo /usr/local/cuda-X.Y/bin/cuda-uninstaller
sudo apt install nvidia-cuda-toolkit


sudo apt-get --purge remove "*cublas*" "cuda*" "nsight*" 

Którą wersję SDK wybrać ?

  • The Streaming Multiprocessor (SM) version of your GPU determines which CUDA toolkit still supports it.
  • if your compute capability is 6.1 us sm_61 and compute_61
  • NVIDIA GPU Compute Capability

apt

[edytuj]
sudo apt install cuda-toolkit
sudo apt install nvidia-cuda-toolkit

wynik apt-get

[edytuj]
  • pakiet „cuda” nie jest częścią oficjalnego repozytorium Ubuntu
sudo apt-get -y install cuda
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libcufile-11-4 : Depends: liburcu6 but it is not installable
 libnvidia-decode-470 : Depends: libnvidia-compute-470 (= 470.42.01-0ubuntu1) but 470.199.02-0ubuntu0.22.04.1 is to be installed
 nvidia-driver-470 : Depends: libnvidia-compute-470 (= 470.42.01-0ubuntu1) but 470.199.02-0ubuntu0.22.04.1 is to be installed
                     Recommends: nvidia-prime (>= 0.8) but it is not going to be installed
                     Recommends: libnvidia-compute-470:i386 (= 470.42.01-0ubuntu1)
                     Recommends: libnvidia-decode-470:i386 (= 470.42.01-0ubuntu1)
                     Recommends: libnvidia-encode-470:i386 (= 470.42.01-0ubuntu1)
                     Recommends: libnvidia-ifr1-470:i386 (= 470.42.01-0ubuntu1)
                     Recommends: libnvidia-fbc1-470:i386 (= 470.42.01-0ubuntu1)
                     Recommends: libnvidia-gl-470:i386 (= 470.42.01-0ubuntu1)
 xserver-xorg-video-nvidia-470 : Depends: xorg-video-abi-24 but it is not installable or
                                          xorg-video-abi-23 but it is not installable or
                                          xorg-video-abi-20 but it is not installable or
                                          xorg-video-abi-19 but it is not installable or
                                          xorg-video-abi-18 but it is not installable or
                                          xorg-video-abi-15 but it is not installable or
                                          xorg-video-abi-14 but it is not installable or
                                          xorg-video-abi-13 but it is not installable or
                                          xorg-video-abi-12 but it is not installable or
                                          xorg-video-abi-11 but it is not installable or
                                          xorg-video-abi-10 but it is not installable or
                                          xorg-video-abi-8 but it is not installable or
                                          xorg-video-abi-6.0 but it is not installable
E: Unable to correct problems, you have held broken packages.

Wynik

[edytuj]
Existing package manager installation of the driver found. It is strongly    │
│ recommended that you remove this before continuing.                          │
│ Abort                                                                        │
│ Continue  


Failed to verify gcc version. See log at /var/log/cuda-installer.log for details.

W pliku /var/log/cuda-installer.log :

  • [INFO]: gcc version: gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04.1)
  • [ERROR]: unsupported compiler version: 11.3.0.



W systemie jest: gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0

Rozwiązanie problemu :

Enter CUDA Samples Location
 [ default is /home/a ]: 

Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
Missing recommended library: libXmu.so

Installing the CUDA Samples in /home/a ...
Copying samples to /home/a/NVIDIA_CUDA-8.0_Samples now...
Finished copying samples.

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-8.0
Samples:  Installed in /home/a, but missing recommended libraries

Please make sure that
 -   PATH includes /usr/local/cuda-8.0/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin

Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
    sudo <CudaInstaller>.run -silent -driver

Logfile is /tmp/cuda_install_7699.log

Usuwanie starych wersji

[edytuj]
 sudo ./uninstall_cuda_8.0.pl

lub


sudo apt-get --purge remove "*cublas*" "cuda*" "nsight*"


pakiety

[edytuj]

Ubuntu:

cat /var/lib/apt/lists/*cuda*Packages | grep "Package:" 
Package: libcufft-11-4
Package: cuda-nsight-systems-11-4
Package: nvidia-driver-470
Package: nvidia-fabricmanager-dev-470
Package: cuda-cupti-11-4
Package: nvidia-fs
Package: libnvidia-gl-430
Package: nvidia-kernel-common-470
Package: libnvidia-decode-430
Package: cuda-cudart-11-4
Package: cuda-driver-dev-11-4
Package: xserver-xorg-video-nvidia-470
Package: cuda-toolkit-11-4
Package: libcusolver-dev-11-4
Package: cuda-memcheck-11-4
Package: nvidia-compute-utils-470
Package: libnvidia-decode-470
Package: cuda-nvml-dev-11-4
Package: libnvidia-fbc1-430
Package: cuda-compiler-11-4
Package: libnvidia-cfg1-470
Package: cuda-drivers-fabricmanager
Package: libcublas-dev-11-4
Package: cuda-documentation-11-4
Package: cuda-toolkit-config-common
Package: nvidia-settings
Package: cuda-nvtx-11-4
Package: nvidia-driver-430
Package: cuda-demo-suite-11-4
Package: libnvidia-fbc1-470
Package: libnpp-11-4
Package: nvidia-utils-430
Package: cuda-nvvp-11-4
Package: cuda-cuobjdump-11-4
Package: cuda-nvprof-11-4
Package: cuda-toolkit-11-config-common
Package: libcublas-11-4
Package: nvidia-compute-utils-430
Package: cuda-drivers-470
Package: cuda-gdb-src-11-4
Package: cuda-drivers
Package: cuda-cudart-dev-11-4
Package: cuda-cuxxfilt-11-4
Package: cuda-11-4
Package: libnvidia-extra-470
Package: libnvidia-common-430
Package: libnvidia-cfg1-430
Package: cuda-libraries-dev-11-4
Package: cuda-libraries-11-4
Package: libnvjpeg-dev-11-4
Package: libcufile-11-4
Package: libnvjpeg-11-4
Package: nvidia-utils-470
Package: nvidia-gds-11-4
Package: libcusparse-dev-11-4
Package: cuda-gdb-11-4
Package: nvidia-modprobe
Package: cuda-nsight-compute-11-4
Package: cuda-nvprune-11-4
Package: cuda
Package: xserver-xorg-video-nvidia-430
Package: libxnvctrl0
Package: cuda-nvcc-11-4
Package: libnvidia-encode-470
Package: nvidia-headless-no-dkms-470
Package: libnpp-dev-11-4
Package: cuda-drivers-fabricmanager-470
Package: nvidia-kernel-common-430
Package: nvidia-dkms-430
Package: libcurand-dev-11-4
Package: cuda-nvrtc-11-4
Package: libnvidia-compute-470
Package: libnvidia-ifr1-430
Package: libnvidia-ifr1-470
Package: nvidia-fs-dkms
Package: libnvidia-nscq-470
Package: nvidia-kernel-source-430
Package: libcurand-11-4
Package: cuda-compat-11-4
Package: cuda-visual-tools-11-4
Package: cuda-nvrtc-dev-11-4
Package: libnvidia-compute-430
Package: libnvidia-encode-430
Package: gds-tools-11-4
Package: cuda-cccl-11-4
Package: nvidia-dkms-470
Package: libxnvctrl-dev
Package: libcusolver-11-4
Package: cuda-samples-11-4
Package: cuda-sanitizer-11-4
Package: libnvidia-common-470
Package: nvidia-headless-470
Package: nvidia-headless-430
Package: nvidia-gds
Package: cuda-tools-11-4
Package: libcusparse-11-4
Package: nvidia-headless-no-dkms-430
Package: nsight-compute-2021.2.0
Package: cuda-minimal-build-11-4
Package: libnvidia-gl-470
Package: cuda-toolkit-11-4-config-common
Package: cuda-runtime-11-4
Package: nvidia-fabricmanager-470
Package: nvidia-kernel-source-470
Package: libcufft-dev-11-4
Package: cuda-nsight-11-4
Package: cuda-command-line-tools-11-4
Package: cuda-nvdisasm-11-4
Package: libcufile-dev-11-4
Package: cuda-cupti-dev-11-4
Package: nsight-systems-2021.2.4

Problemy

[edytuj]
  • CUDA incompatible with my gcc version[23]

GPU

[edytuj]

Procesor GPU składa się z:

  • multiprocesorów
  • pamięci głównej karty graficznej

Multiprocesor składa się z:

  • 8 lub 16 procesorów
  • pamięci multiprocesora (bardzo szybka, wspólna dla procesorów)

CUDA cores per SM:

  • 32 (Compute Capability 2.0) CUDA cores per SM
  • 48 (2.1) CUDA cores per SM
  • Compute Capability 3.0 (Kepler) now increases cores/SM hugely - to 192



cuda wersje

[edytuj]
  • Kepler-class GPUs and CUDA 5.0


Zobacz

Z linii poleceń (an.g command line CLI ):[24]

/usr/local/cuda/bin/nvcc --version  # gives the CUDA compiler version 
nvcc --version #  the CUDA toolkit version 
cat /usr/local/cuda/version.txt

Z poziomu aplikacja

  • the runtime API version: cudaRuntimeGetVersion()
  • the driver API version: cudaDriverGetVersion()
  • deviceQuery ( SDK sample app )

api

[edytuj]
  • driver api[25]
  • runtime api
[edytuj]

Zmienne[26]

  • CUDA_NVCC_EXECUTABLE
  • CUDA_INCLUDE_DIRS
  • CUDA_CUDART_LIBRARY
  • CUDA_TOOLKIT_ROOT_DIR
  • MAX_GCC_VERSION ( env var for that GCC version)
export CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
set(CUDA_TOOLKIT_ROOT_DIR "/usr/local/cuda")

Typy liczb

[edytuj]
  • zmiennoprzecinkowe[27]
    • podwójnej precyzji są dostępne dla GPU o potencjale obliczeniowym 1.3 i większym (ang. 1.3-capable card)
    • double-double [28]

Można wybrać potencjał obliczeniowy za pomocą opcji kompilatora:

nvcc --gpu-architecture sm_13 

lub

-arch=sm_13

lub [29]

--gpu-name sm_13

Lista dostępnych funkcji podwójnej precyzji w bibliotece CUDA[30]

Struktura obliczeń

[edytuj]

Obliczenie K dzieli się na:

  • gridy g składające się z bloków,
  • bloki b, które dzielą się na wątki w.[31]
 
 
 

Struktura typowego programu CUDA

[edytuj]
  • skopiować dane z pamięci komputera do pamięci karty graficznej
  • skopiować dane do pamięci multiprocesora
  • wykonać obliczenia na multiprocesorach
  • skopiować częściowe wyniki z multiprocesorów do pamięci głównej karty graficznej
  • skopiować końcowy wynik do pamięci komputera
Struktura programu CUDA

Jak zacząć

[edytuj]

Co potrzebujemy wg Nvidia[32]


Plik :[33]

  • zapisujemy z rozszerzeniem cu
e.cu
  • kompilujemy kompilatorem firmy NVIDIA:
nvcc e.cu 
  • uruchamiamy:
./a.out

Programowanie

[edytuj]

Pierwszy program

[edytuj]

Przykładowy program pokazujący ilość dostępnych kart cuda[34]

    #include <stdio.h>
    #include <cuda.h>

    int main(void)
    {

       int nDevices;
       
       cudaGetDeviceCount(&nDevices);
       printf("Number of CUDA devices = %d\n", nDevices);
       
       return 0;
    }

Kompilacja:

gcc c.c -Wall

daje efekt:

c.c:2:22: fatal error: cuda.h: Nie ma takiego pliku ani katalogu


Szukamy cuda.h:

 udpatedb
 locate cuda.h

otrzymujemy:

/usr/include/linux/cuda.h
/usr/src/linux-headers-3.11.0-12/include/linux/cuda.h
/usr/src/linux-headers-3.11.0-12/include/uapi/linux/cuda.h
/usr/src/linux-headers-3.11.0-12-generic/include/linux/cuda.h
/usr/src/linux-headers-3.11.0-13/include/linux/cuda.h
/usr/src/linux-headers-3.11.0-13/include/uapi/linux/cuda.h
/usr/src/linux-headers-3.11.0-13-generic/include/linux/cuda.h
/usr/src/linux-headers-3.11.0-14/include/linux/cuda.h
/usr/src/linux-headers-3.11.0-14/include/uapi/linux/cuda.h
/usr/src/linux-headers-3.11.0-14-generic/include/linux/cuda.h
/usr/src/linux-headers-3.11.0-15/include/linux/cuda.h
/usr/src/linux-headers-3.11.0-15/include/uapi/linux/cuda.h
/usr/src/linux-headers-3.11.0-15-generic/include/linux/cuda.h

ale tu chodzi o katalog:

/usr/local/cuda/include/


który jest pusty ...

hello.cu

[edytuj]

Linki

[edytuj]

biblioteki

[edytuj]

Słownik

[edytuj]
  • cuda-gdb - The NVIDIA CUDA Debugger
  • nvcc - The NVIDIA CUDA Compiler
  • cuobjdump - The NVIDIA CUDA Object Utility
  • nvdisasm - The NVIDIA CUDA disassembler
  • nvprune - The NVIDIA CUDA Prune Tool
  • nsight - NVIDIA NSight, Eclipse Edition
  • nvvp - The NVIDIA CUDA Visual Profiler
  • nvprof - The NVIDIA CUDA Command-Line Profiler
  • cuda-memcheck - The NVIDIA CUDA Check Tool
  • API [42]
  • blok = suma wątków wykonywanych przez pojedynczy multiprocesor
  • device = (pl. urządzenie) = karta graficzna
  • grid = Wszystkie bloki pracujące nad jednym kernelem nazywamy gridem. Gridów może być maksymalnie tyle co multiprocesorów
  • host = CPU
  • GPU = procesor karty graficznej
  • CPU = procesor płyty głównej
  • kernel =
    • jądro kodu obliczeniowego
    • kod pojedynczego wątku CUDA[43]
    • "funkcja wykonywana na karcie graficznej równolegle przez CUDA-wątki" [44]
  • nvcc - kompilator c firmy NVIDIA
  • wątek = obliczenie wykonywane na pojedynczym procesorze GPU
  • Cuda Cores are also called Stream Processors (SP)
  • Streaming Multiprocessors (SM)
  • grids which maps blocks to the GPU
  • blocks which map threads to Stream Processors
  • warp is always formed by 32 threads and all threads of a warp are executed simulaneously[45]

Pomoc

[edytuj]

Odnośniki

[edytuj]
  1. Wstęp do CUDA cz. I autor: Szymon Zimnowoda
  2. docs.nvidia : cuda-quick-start-guide
  3. instalacji : ask ubuntu
  4. | Instalacja CUDA Thomas Krenn Wiki
  5. Cuda HELP UBUNTU
  6. tutorials.ubuntu : gpu-data-processing-inside-lxd
  7. linuxhandbook : setup-opencl-linux-docker
  8. cuda-getting-started-guide-for-linux
  9. linuxconfig: how-to-check-cuda-version-on-ubuntu-20-04-focal-fossa-linux
  10. Lista GPU odpowiednich dla CUDA
  11. techspot : products nvidia-geforce-gtx-770.91181
  12. techpowerup : gpu-specs geforce-gtx-770.c1856
  13. CUDA Toolkit
  14. askubuntu question: how-can-i-install-cuda-on-ubuntu-16-04
  15. devtalk.nvidia : cuda-8-0-toolkit-install-nvcc-not-found-ubuntu-16-04
  16. downloads
  17. Installing and testing CUDA in Ubuntu 14.04
  18. Yputube : Ubuntu 12.04 - Installing Nvidia CUDA Developer Driver [OUTDATED]
  19. Accelerated Linux Driver Set README and Installation Guide
  20. nvidia cuda-installation-guide-linux - table
  21. stackoverflow question : cuda-incompatible-with-my-gcc-version
  22. nvidia cuda-toolkit
  23. stackoverflow question: cuda-incompatible-with-my-gcc-version
  24. stackoverflow question: how-to-get-the-cuda-version
  25. nvidia cuda: driver-vs-runtime-api
  26. stackoverflow question : installing-cuda-for-linux-could-not-find-cuda
  27. Increasing the float/double precision, how is this done?
  28. Double double precision arithmetic library for Cuda now available
  29. CUDA Support/Enabling double-precision from Computer Science Support Wiki
  30. Double Precision Mathematical Functions from NVIDIA CUDA Library Documentation 4.2
  31. W Śmietanka : Programowanie na platformie CUDA. Delta 448 (9/2011)
  32. NVIDIA GPU Computing Documentation
  33. [http://www.eti.pg.gda.pl/katedry/kask/dydaktyka/Przetwarzanie_Rownolegle_CUDA/CELL/01-cuda.pdf CUDA Programming Paweł Czarnul]
  34. na forum ubuntu - program użytkownika jablondyn
  35. Wykłady Wojciecha Kwedlo
  36. wykłady wydziału ETI Politechniki Gdańskiej
  37. Generowanie i wizualizacja zbioru Mandelbrota na CUDA - Paweł Nowak
  38. Why aren't we programming on the GPU?
  39. [Julia Set for the Complex Function f(z) = z^3 – 1, in C and CUDA by Stephen on March 4th, 2012]
  40. github gpuprec
  41. stackoverflow question : cuda-how-to-work-with-complex-numbers?
  42. Mirek SOcha : CUDA
  43. Programowanie na platformie CUDA - Wojciech Śmietanka. Delta 448 (9/2011)
  44. Wstęp do CUDA Cz. II autor: ZimnowodaSzymon
  45. stackoverflow question: streaming-multiprocessors-blocks-and-threads-cuda