colab从CPU切换到GPU以及配置查看

查看cuda版本以及驱动安装

!nvcc -V

!dpkg --list | grep nvidia-*

运行结果如下:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
ii  libnvidia-cfg1-418:amd64               430.50-0ubuntu0.18.04.1                           amd64        Transitional package for libnvidia-cfg1-430
ii  libnvidia-cfg1-430:amd64               430.50-0ubuntu0.18.04.1                           amd64        NVIDIA binary OpenGL/GLX configuration library
ii  libnvidia-common-418                   430.50-0ubuntu0.18.04.1                           all          Transitional package for libnvidia-common-430
ii  libnvidia-common-430                   430.50-0ubuntu0.18.04.1                           all          Shared files used by the NVIDIA libraries
ii  libnvidia-compute-418:amd64            430.50-0ubuntu0.18.04.1                           amd64        Transitional package for libnvidia-compute-430
ii  libnvidia-compute-430:amd64            430.50-0ubuntu0.18.04.1                           amd64        NVIDIA libcompute package
ii  libnvidia-decode-418:amd64             430.50-0ubuntu0.18.04.1                           amd64        Transitional package for libnvidia-decode-430
ii  libnvidia-decode-430:amd64             430.50-0ubuntu0.18.04.1                           amd64        NVIDIA Video Decoding runtime libraries
ii  libnvidia-encode-418:amd64             430.50-0ubuntu0.18.04.1                           amd64        Transitional package for libnvidia-encode-430
ii  libnvidia-encode-430:amd64             430.50-0ubuntu0.18.04.1                           amd64        NVENC Video Encoding runtime library
ii  libnvidia-fbc1-418:amd64               430.50-0ubuntu0.18.04.1                           amd64        Transitional package for libnvidia-fbc1-430
ii  libnvidia-fbc1-430:amd64               430.50-0ubuntu0.18.04.1                           amd64        NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-gl-418:amd64                 430.50-0ubuntu0.18.04.1                           amd64        Transitional package for libnvidia-gl-430
ii  libnvidia-gl-430:amd64                 430.50-0ubuntu0.18.04.1                           amd64        NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii  libnvidia-ifr1-418:amd64               430.50-0ubuntu0.18.04.1                           amd64        Transitional package for libnvidia-ifr1-430
ii  libnvidia-ifr1-430:amd64               430.50-0ubuntu0.18.04.1                           amd64        NVIDIA OpenGL-based Inband Frame Readback runtime library
ii  nvidia-compute-utils-418:amd64         430.50-0ubuntu0.18.04.1                           amd64        Transitional package for nvidia-compute-utils-430
ii  nvidia-compute-utils-430               430.50-0ubuntu0.18.04.1                           amd64        NVIDIA compute utilities
ii  nvidia-dkms-418                        430.50-0ubuntu0.18.04.1                           amd64        Transitional package for nvidia-dkms-430
ii  nvidia-dkms-430                        430.50-0ubuntu0.18.04.1                           amd64        NVIDIA DKMS package
ii  nvidia-driver-418                      430.50-0ubuntu0.18.04.1                           amd64        Transitional package for nvidia-driver-430
ii  nvidia-driver-430                      430.50-0ubuntu0.18.04.1                           amd64        NVIDIA driver metapackage
ii  nvidia-kernel-common-418:amd64         430.50-0ubuntu0.18.04.1                           amd64        Transitional package for nvidia-kernel-common-430
ii  nvidia-kernel-common-430               430.50-0ubuntu0.18.04.1                           amd64        Shared files used with the kernel module
ii  nvidia-kernel-source-418               430.50-0ubuntu0.18.04.1                           amd64        Transitional package for nvidia-kernel-source-430
ii  nvidia-kernel-source-430               430.50-0ubuntu0.18.04.1                           amd64        NVIDIA kernel source package
ii  nvidia-modprobe                        418.87.01-0ubuntu1                                amd64        Load the NVIDIA kernel driver and create device files
ii  nvidia-opencl-dev:amd64                9.1.85-3ubuntu1                                   amd64        NVIDIA OpenCL development files
ii  nvidia-settings                        418.87.01-0ubuntu1                                amd64        Tool for configuring the NVIDIA graphics driver
ii  nvidia-utils-418:amd64                 430.50-0ubuntu0.18.04.1                           amd64        Transitional package for nvidia-utils-430
ii  nvidia-utils-430                       430.50-0ubuntu0.18.04.1                           amd64        NVIDIA driver support binaries
ii  xserver-xorg-video-nvidia-418:amd64    430.50-0ubuntu0.18.04.1                           amd64        Transitional package for xserver-xorg-video-nvidia-430
ii  xserver-xorg-video-nvidia-430          430.50-0ubuntu0.18.04.1                           amd64        NVIDIA binary Xorg driver

###############################查看CPU##############################

!cat /proc/cpuinfo | grep "cpu cores" | uniq

!cat /proc/cpuinfo |grep "processor"|wc -l

运行后会发现是双核四线程

 

###############################查看GPU##############################

1.代码执行程序->更改运行时类型

colab从CPU切换到GPU以及配置查看_第1张图片

2.

colab从CPU切换到GPU以及配置查看_第2张图片

打开GPU以后再运行下述命令才会有运行结果.

 

命令:

!apt install lshw -y

!lshw -C display

结果:

  *-display
       description: 3D controller
       product: GK210GL [Tesla K80]
       vendor: NVIDIA Corporation
       physical id: 4
       bus info: pci@0000:00:04.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: msi pm bus_master cap_list
       configuration: driver=nvidia latency=0
       resources: iomemory:80-7f iomemory:c0-bf irq:37 memory:fc000000-fcffffff memory:800000000-bffffffff memory:c00000000-c01ffffff ioport:c000(size=128)


------------------------------------------------------------------------------------

命令:

!lspci

结果:

00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 03)
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:03.0 Non-VGA unclassified device: Red Hat, Inc. Virtio SCSI
00:04.0 3D controller: NVIDIA Corporation GK210GL [Tesla K80] (rev a1)
00:05.0 Ethernet controller: Red Hat, Inc. Virtio network device

所以根据文档[1]可知,Google的colab是不支持lightgbm的加速的.

所以colab中,CPU版本的lightgbm运行速度比GPU版本的lightgbm运行速度更快

 

##############################开启最大内存######################################

默认内存是12GB,下面是开启25GB的方法:

先把内存耗尽,然后colab就会弹出提升内存的选项:

耗尽内存的代码如下:

lists=True
while True:
    lists.append(1111111111111111111111)

colab从CPU切换到GPU以及配置查看_第3张图片

colab从CPU切换到GPU以及配置查看_第4张图片

colab从CPU切换到GPU以及配置查看_第5张图片

另外:

如果想要300多G的硬盘,必须设置设备为GPU,python3

 

 

Reference:

[1]https://lightgbm.readthedocs.io/en/latest/GPU-Performance.html

你可能感兴趣的:(Colaboratory)