Skip to content

Instantly share code, notes, and snippets.

@andreinechaev
Created April 4, 2018 01:32
Show Gist options
  • Save andreinechaev/f6175fa7a26b9a1850bbe3cb16f7770a to your computer and use it in GitHub Desktop.
Save andreinechaev/f6175fa7a26b9a1850bbe3cb16f7770a to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Cuda-8.ipynb",
"version": "0.3.2",
"views": {},
"default_view": {},
"provenance": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"cells": [
{
"metadata": {
"id": "e-dNfpS7KXvv",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 1
}
],
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "a90dea36-5ded-4d95-b651-b03c5d43d33e",
"executionInfo": {
"status": "ok",
"timestamp": 1522803549951,
"user_tz": 240,
"elapsed": 3179,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!apt update -qq"
],
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"text": [
"10 packages can be upgraded. Run 'apt list --upgradable' to see them.\r\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "s7Frpc7ZKdnH",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 21
}
],
"base_uri": "https://localhost:8080/",
"height": 309
},
"outputId": "28ed28bc-af08-4d09-fa1b-cd55bfcb8fdc",
"executionInfo": {
"status": "ok",
"timestamp": 1522803647645,
"user_tz": 240,
"elapsed": 15326,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb"
],
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"text": [
"--2018-04-04 01:00:33-- https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb\r\n",
"Resolving developer.nvidia.com (developer.nvidia.com)... 192.229.182.215\n",
"Connecting to developer.nvidia.com (developer.nvidia.com)|192.229.182.215|:443... connected.\n",
"HTTP request sent, awaiting response... 302 Found\n",
"Location: http://developer.download.nvidia.com/compute/cuda/8.0/secure/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb?KtyAC8MncGZXbmrHRWyA_PL6G0UKblaSdC8n975sAE1w7lyJbGUNeeMT3ycALEHNtcc62vLxu1_LU3ojI0ti0nxaN2Ur2VGHJ6qd1KeT4XhXO3Ph2GzxMctj7DzoPRbSXqfqE5KFYjCR6EavmbwrMK2lhNes_A4TYsvaJYLpjwDbdyBxSB4dyvNpHg4QVD8C4Sp1wxw1iQ3xNrydEbClgseefQ [following]\n",
"--2018-04-04 01:00:34-- http://developer.download.nvidia.com/compute/cuda/8.0/secure/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb?KtyAC8MncGZXbmrHRWyA_PL6G0UKblaSdC8n975sAE1w7lyJbGUNeeMT3ycALEHNtcc62vLxu1_LU3ojI0ti0nxaN2Ur2VGHJ6qd1KeT4XhXO3Ph2GzxMctj7DzoPRbSXqfqE5KFYjCR6EavmbwrMK2lhNes_A4TYsvaJYLpjwDbdyBxSB4dyvNpHg4QVD8C4Sp1wxw1iQ3xNrydEbClgseefQ\n",
"Resolving developer.download.nvidia.com (developer.download.nvidia.com)... 192.229.211.70, 2606:2800:21f:3aa:dcf:37b:1ed6:1fb\n",
"Connecting to developer.download.nvidia.com (developer.download.nvidia.com)|192.229.211.70|:80... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 1913589814 (1.8G) [application/x-deb]\n",
"Saving to: ‘cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb’\n",
"\n",
"cuda-repo-ubuntu160 100%[===================>] 1.78G 149MB/s in 13s \n",
"\n",
"2018-04-04 01:00:47 (143 MB/s) - ‘cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb’ saved [1913589814/1913589814]\n",
"\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "41Y3z-wPK2iR",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 4
}
],
"base_uri": "https://localhost:8080/",
"height": 119
},
"outputId": "7cbcbe73-0e46-4bfc-9c13-60af3a0c9ed1",
"executionInfo": {
"status": "ok",
"timestamp": 1522803761985,
"user_tz": 240,
"elapsed": 42292,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb 2> /dev/null"
],
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"text": [
"Selecting previously unselected package cuda-repo-ubuntu1604-8-0-local-ga2.\n",
"(Reading database ... 91203 files and directories currently installed.)\n",
"Preparing to unpack cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb ...\n",
"Unpacking cuda-repo-ubuntu1604-8-0-local-ga2 (8.0.61-1) ...\n",
"Setting up cuda-repo-ubuntu1604-8-0-local-ga2 (8.0.61-1) ...\n",
"OK\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "NYD9NCuFLApc",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 1
}
],
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "36ef5b2f-2bde-49cd-94f0-998870b543b9",
"executionInfo": {
"status": "ok",
"timestamp": 1522803938939,
"user_tz": 240,
"elapsed": 1793,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!apt-key add /var/cuda-repo-8-0-local-ga2/7fa2af80.pub"
],
"execution_count": 9,
"outputs": [
{
"output_type": "stream",
"text": [
"OK\r\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "VwhVnv-OLzVg",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 9
}
],
"base_uri": "https://localhost:8080/",
"height": 238
},
"outputId": "5bea6765-6245-46a5-92b4-70275007b3c6",
"executionInfo": {
"status": "ok",
"timestamp": 1522804935361,
"user_tz": 240,
"elapsed": 5675,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!apt-get update\n",
"!apt-get install cuda gcc-5 g++-5 -y -qq"
],
"execution_count": 37,
"outputs": [
{
"output_type": "stream",
"text": [
"\r0% [Working]\r \rGet:1 file:/var/cuda-repo-8-0-local-ga2 InRelease\r\n",
"\r \rIgn:1 file:/var/cuda-repo-8-0-local-ga2 InRelease\r\n",
"\r0% [Connecting to archive.ubuntu.com] [Connecting to security.ubuntu.com (91.18\r \rGet:2 file:/var/cuda-repo-9-1-local InRelease\r\n",
"\r \rIgn:2 file:/var/cuda-repo-9-1-local InRelease\r\n",
"\r0% [Connecting to archive.ubuntu.com] [Connecting to security.ubuntu.com (91.18\r \rGet:3 file:/var/cuda-repo-8-0-local-ga2 Release [574 B]\r\n",
"Get:4 file:/var/cuda-repo-9-1-local Release [574 B]\n",
"Get:3 file:/var/cuda-repo-8-0-local-ga2 Release [574 B]\n",
"Get:4 file:/var/cuda-repo-9-1-local Release [574 B]\n",
"Hit:5 http://archive.ubuntu.com/ubuntu artful InRelease\n",
"Hit:6 http://security.ubuntu.com/ubuntu artful-security InRelease\n",
"Hit:8 http://archive.ubuntu.com/ubuntu artful-updates InRelease\n",
"Hit:9 http://archive.ubuntu.com/ubuntu artful-backports InRelease\n",
"Reading package lists... Done\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "Fbgc2-nYMRoS",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
},
"cell_type": "code",
"source": [
"!ln -s /usr/bin/gcc-5 /usr/local/cuda/bin/gcc\n",
"!ln -s /usr/bin/g++-5 /usr/local/cuda/bin/g++"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "6V7Nl8ckMj0i",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 1
}
],
"base_uri": "https://localhost:8080/",
"height": 85
},
"outputId": "ca1633b5-b8b9-4ae6-ecaf-d8e701d403b7",
"executionInfo": {
"status": "ok",
"timestamp": 1522804121910,
"user_tz": 240,
"elapsed": 1387,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!/usr/local/cuda/bin/nvcc --version"
],
"execution_count": 17,
"outputs": [
{
"output_type": "stream",
"text": [
"nvcc: NVIDIA (R) Cuda compiler driver\r\n",
"Copyright (c) 2005-2017 NVIDIA Corporation\r\n",
"Built on Fri_Nov__3_21:07:56_CDT_2017\r\n",
"Cuda compilation tools, release 9.1, V9.1.85\r\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "xU4TdBzZMsmi",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 6
}
],
"base_uri": "https://localhost:8080/",
"height": 136
},
"outputId": "6faac25d-d6b8-47fd-bf7d-041d6224f36c",
"executionInfo": {
"status": "ok",
"timestamp": 1522804431981,
"user_tz": 240,
"elapsed": 2665,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!apt install cuda-8.0"
],
"execution_count": 21,
"outputs": [
{
"output_type": "stream",
"text": [
"Reading package lists... Done\n",
"Building dependency tree \n",
"Reading state information... Done\n",
"Note, selecting 'cuda-8-0' for regex 'cuda-8.0'\n",
"Note, selecting 'libcuda-8.0-1' for regex 'cuda-8.0'\n",
"cuda-8-0 is already the newest version (8.0.61-1).\n",
"0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "jEzCSFhAN5HO",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 1
}
],
"base_uri": "https://localhost:8080/",
"height": 85
},
"outputId": "5410fb98-0887-4bba-93f6-d9eee64d2452",
"executionInfo": {
"status": "ok",
"timestamp": 1522804456901,
"user_tz": 240,
"elapsed": 1333,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!/usr/local/cuda/bin/nvcc --version"
],
"execution_count": 23,
"outputs": [
{
"output_type": "stream",
"text": [
"nvcc: NVIDIA (R) Cuda compiler driver\r\n",
"Copyright (c) 2005-2016 NVIDIA Corporation\r\n",
"Built on Tue_Jan_10_13:22:03_CST_2017\r\n",
"Cuda compilation tools, release 8.0, V8.0.61\r\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "4WFx2w_gN-QU",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 1
}
],
"base_uri": "https://localhost:8080/",
"height": 306
},
"outputId": "23c151d0-4540-48d7-9be1-9324fa8eb6b5",
"executionInfo": {
"status": "ok",
"timestamp": 1522804603366,
"user_tz": 240,
"elapsed": 1318,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!/opt/bin/nvidia-smi"
],
"execution_count": 25,
"outputs": [
{
"output_type": "stream",
"text": [
"Wed Apr 4 01:16:43 2018 \r\n",
"+-----------------------------------------------------------------------------+\r\n",
"| NVIDIA-SMI 384.111 Driver Version: 384.111 |\r\n",
"|-------------------------------+----------------------+----------------------+\r\n",
"| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\r\n",
"| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\r\n",
"|===============================+======================+======================|\r\n",
"| 0 Tesla K80 Off | 00000000:00:04.0 Off | 0 |\r\n",
"| N/A 37C P8 32W / 149W | 1MiB / 11439MiB | 0% Default |\r\n",
"+-------------------------------+----------------------+----------------------+\r\n",
" \r\n",
"+-----------------------------------------------------------------------------+\r\n",
"| Processes: GPU Memory |\r\n",
"| GPU PID Type Process name Usage |\r\n",
"|=============================================================================|\r\n",
"| No running processes found |\r\n",
"+-----------------------------------------------------------------------------+\r\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "r51C32a6OiKi",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 1
}
],
"base_uri": "https://localhost:8080/",
"height": 357
},
"outputId": "24ee853f-f9c9-4a8b-b2a8-5f011afde91a",
"executionInfo": {
"status": "ok",
"timestamp": 1522805309954,
"user_tz": 240,
"elapsed": 4638,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!/usr/local/cuda/bin/nvcc -arch=sm_37 -std=c++11 -o app.out main.cu --run"
],
"execution_count": 44,
"outputs": [
{
"output_type": "stream",
"text": [
"0.590188\r\n",
"0.897824\r\n",
"1.45411\r\n",
"0.564272\r\n",
"0.0745404\r\n",
"1.61721\r\n",
"1.18085\r\n",
"1.46339\r\n",
"0.375699\r\n",
"1.12175\r\n",
"1.73591\r\n",
"0.957393\r\n",
"0.914143\r\n",
"0.441414\r\n",
"0.958221\r\n",
"0.823556\r\n",
"0.58471\r\n",
"0.457891\r\n",
"1.37826\r\n",
"0.820289\r\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "kbK51yMFO0SW",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 2
}
],
"base_uri": "https://localhost:8080/",
"height": 51
},
"outputId": "d4f83a6a-0853-47ea-e874-1486202aeaf3",
"executionInfo": {
"status": "ok",
"timestamp": 1522805223894,
"user_tz": 240,
"elapsed": 2969,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!find / -name nvprof"
],
"execution_count": 39,
"outputs": [
{
"output_type": "stream",
"text": [
"/usr/local/cuda-8.0/bin/nvprof\n",
"/usr/local/cuda-9.1/bin/nvprof\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "JYN0tuBpQ3gf",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
},
"output_extras": [
{
"item_id": 3
}
],
"base_uri": "https://localhost:8080/",
"height": 799
},
"outputId": "023e6a9e-c043-4fed-f23c-2ff4b370a4db",
"executionInfo": {
"status": "ok",
"timestamp": 1522805374347,
"user_tz": 240,
"elapsed": 1745,
"user": {
"displayName": "Andrei Nechaev",
"photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
"userId": "109327432569096432513"
}
}
},
"cell_type": "code",
"source": [
"!/usr/local/cuda/bin/nvprof ./app.out"
],
"execution_count": 46,
"outputs": [
{
"output_type": "stream",
"text": [
"==4919== NVPROF is profiling process 4919, command: ./app.out\n",
"0.590188\n",
"0.897824\n",
"1.45411\n",
"0.564272\n",
"0.0745404\n",
"1.61721\n",
"1.18085\n",
"1.46339\n",
"0.375699\n",
"1.12175\n",
"1.73591\n",
"0.957393\n",
"0.914143\n",
"0.441414\n",
"0.958221\n",
"0.823556\n",
"0.58471\n",
"0.457891\n",
"1.37826\n",
"0.820289\n",
"==4919== Profiling application: ./app.out\n",
"==4919== Profiling result:\n",
"Time(%) Time Calls Avg Min Max Name\n",
"100.00% 9.7280us 1 9.7280us 9.7280us 9.7280us addVec(float*, float*, float*)\n",
"\n",
"==4919== Unified Memory profiling result:\n",
"Device \"Tesla K80 (0)\"\n",
" Count Avg Size Min Size Max Size Total Size Total Time Name\n",
" 2 512.00KB 256.00KB 768.00KB 1.000000MB 183.7440us Host To Device\n",
" 18 60.444KB 4.0000KB 252.00KB 1.062500MB 201.4080us Device To Host\n",
"Total CPU Page faults: 9\n",
"\n",
"==4919== API calls:\n",
"Time(%) Time Calls Avg Min Max Name\n",
" 99.32% 216.65ms 3 72.217ms 33.008us 216.37ms cudaMallocManaged\n",
" 0.22% 480.67us 91 5.2820us 1.9360us 136.56us cuDeviceGetAttribute\n",
" 0.19% 420.65us 3 140.22us 41.349us 230.36us cudaFree\n",
" 0.15% 325.26us 1 325.26us 325.26us 325.26us cudaLaunch\n",
" 0.08% 180.48us 1 180.48us 180.48us 180.48us cuDeviceTotalMem\n",
" 0.02% 36.115us 1 36.115us 36.115us 36.115us cudaDeviceSynchronize\n",
" 0.01% 29.296us 1 29.296us 29.296us 29.296us cuDeviceGetName\n",
" 0.00% 8.2520us 3 2.7500us 1.9770us 3.6550us cuDeviceGetCount\n",
" 0.00% 6.9050us 3 2.3010us 2.0960us 2.6390us cuDeviceGet\n",
" 0.00% 4.8560us 1 4.8560us 4.8560us 4.8560us cudaConfigureCall\n",
" 0.00% 1.7700us 3 590ns 238ns 1.1080us cudaSetupArgument\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "qUXDTDi0RAdm",
"colab_type": "code",
"colab": {
"autoexec": {
"startup": false,
"wait_interval": 0
}
}
},
"cell_type": "code",
"source": [
""
],
"execution_count": 0,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment