LoginSignup
2
1

More than 1 year has passed since last update.

GTX TITAN(Kepler) Linux でコスパよい倍精度計算するメモ

Last updated at Posted at 2021-04-12

背景

自前アプリなどで GPU で倍精度(fp64)計算の性能が必要だが, 倍精度性能高い NVIDIA GPU はお高い(GV100 など, Titan V でも eBay で中古 30 万円くらい)

GTX TITAN(Kepler, 6GB)が入手しやすく比較的安価(中古で 2.5 ~ 3 万円くらい)で倍精度性能高い(Spec では 1 TFlops くらいあります)のでとりあえず GTX TITAN で試してみます.
(ただし CUDA11 では deprecated 扱いであるので注意)

GTX TITAN は sm_35(GK110) になります. ECC はありません.

一応 fp64 も IEEE754-2008 準拠になっています.

GTX TITAN は 2021/04 時点でゲーミング系 GPU の最新である Ampere 系の 3090 よりも fp64 性能高いです.

A6000, RTX 3090 の倍精度性能のメモ
https://qiita.com/syoyo/items/46b9c7a890153d64acf6

2021/09/17 追記: Tesla P100 12 GB(Spec では倍精度 4.7 TF) が eBay で 10 万円以下も出始めました. P100 という手もありそうです(ただしファン(冷却)をどうするか考える必要がある).

倍精度設定

そのままでは倍精度にはリミットがかかっているので(消費電力の関係と思われる), nvidia-settings で倍精度を有効(フルスピード)にします.
(nvidia-smi --gom は TITAN では利用できない)

headless 環境だと nvidia-settings は動かないので, x11vnc あたり入れて設定する必要があります.

NVIDIA GPU の X11 headless setup + X11VNC/RDP 接続のメモ
https://qiita.com/syoyo/items/a14fa891b80bb82a4485

(x11vnc 経由で) nvidia-setteing を開くと, CUDA - Double precision があるのでこれにチェックを入れます!

Screenshot from 2021-04-12 18-43-05.png

(VNC で X11 立ち上がったら, コマンドラインで設定もできるでしょう)

CUDA

CUDA11 では deprecated 扱いです. 動きはするようですが最新の CUDA 関数使うと動かないかもです.
(後述する mixbench-cuda が sm35 に下げてコンパイルしたら動かなかった(途中で timeout error) -> ただ 3080 とかでもやっぱりダメだったので, コード自体になにか問題ありそう)

安定して計算したいのであれば OpenCL を使いましょう.

OpenCL

1.2 が使えます.

OpenCL 3.0 対応は Maxwell 以降でした.

3.0 で使われている advanced な機能不要であれば 1.2 でもよいでしょう
(1.2 だと十分枯れていて安定動作期待できそうですし)

benchmark

mixbench-opencl で試してみます.

nvidia-smi -pl 150 で 150W に powerlimit しての結果です(150 = 設定できる下限).

$ ./mixbench-ocl-alt 
mixbench-ocl/alternating (v0.03-15-g514c757)
Use "-h" argument to see available options
------------------------ Device specifications ------------------------
Platform:            NVIDIA CUDA
Device:              GeForce GTX TITAN/NVIDIA Corporation
Driver version:      460.32.03
Address bits:        64
GPU clock rate:      875 MHz
Total global mem:    6051 MB
Max allowed buffer:  1512 MB
OpenCL version:      OpenCL 1.2 CUDA
Total CUs:           14
-----------------------------------------------------------------------
Buffer size:            64MB
Workgroup size:         256
Workitem stride:        NDRange
Buffer allocation:      Device allocated
Timer:                  CL event based
Warning:                Half precision computations are not supported
Loading kernel source file...
Precompilation of kernels... [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]
----------------------------------------------------------------------------- CSV data -----------------------------------------------------------------------------
Experiment ID, Single Precision ops,,,,              Double precision ops,,,,              Half precision ops,,,,                Integer operations,,, 
Compute iters, Flops/byte, ex.time,  GFLOPS, GB/sec, Flops/byte, ex.time,  GFLOPS, GB/sec, Flops/byte, ex.time,  GFLOPS, GB/sec, Iops/byte, ex.time,   GIOPS, GB/sec
            0,      0.000,   39.66,    0.00, 216.57,      0.000,   83.00,    0.00, 206.98,      0.000,    0.00,    -nan,    inf,     0.000,   39.77,    0.00, 215.98
            1,      0.129,   38.13,   28.16, 218.22,      0.065,   83.07,   12.93, 200.36,      0.258,    0.00,     inf,    inf,     0.129,   38.82,   27.66, 214.35
            2,      0.267,   37.04,   57.98, 217.43,      0.133,   79.82,   26.90, 201.78,      0.533,    0.00,     inf,    inf,     0.267,   36.79,   58.38, 218.91
            3,      0.414,   36.03,   89.40, 216.05,      0.207,   78.03,   41.28, 199.54,      0.828,    0.00,     inf,    inf,     0.414,   36.02,   89.42, 216.09
            4,      0.571,   34.41,  124.80, 218.41,      0.286,   73.13,   58.73, 205.55,      1.143,    0.00,     inf,    inf,     0.571,   34.26,  125.36, 219.37
            5,      0.741,   34.18,  157.06, 212.03,      0.370,   73.13,   73.42, 198.22,      1.481,    0.00,     inf,    inf,     0.741,   27.84,  192.84, 260.33
            6,      0.923,   33.70,  191.16, 207.09,      0.462,   70.70,   91.12, 197.42,      1.846,    0.00,     inf,    inf,     0.923,   25.87,  249.06, 269.81
            7,      1.120,   30.64,  245.32, 219.04,      0.560,   66.37,  113.26, 202.24,      2.240,    0.00,     inf,    inf,     1.120,   28.27,  265.90, 237.41
            8,      1.333,   27.05,  317.58, 238.18,      0.667,   64.26,  133.66, 200.50,      2.667,    0.00,     inf,    inf,     1.333,   29.52,  291.03, 218.27
            9,      1.565,   28.78,  335.76, 214.51,      0.783,   61.64,  156.78, 200.33,      3.130,    0.00,     inf,    inf,     1.565,   30.51,  316.69, 202.33
           10,      1.818,   25.87,  414.98, 228.24,      0.909,   57.87,  185.54, 204.09,      3.636,    0.00,     inf,    inf,     1.818,   31.30,  343.00, 188.65
           11,      2.095,   25.75,  458.69, 218.92,      1.048,   54.78,  215.60, 205.80,      4.190,    0.00,     inf,    inf,     2.095,   31.18,  378.82, 180.80
           12,      2.400,   23.50,  548.26, 228.44,      1.200,   53.38,  241.37, 201.14,      4.800,    0.00,     inf,    inf,     2.400,   32.63,  394.90, 164.54
           13,      2.737,   22.79,  612.40, 223.76,      1.368,   49.71,  280.83, 205.22,      5.474,    0.00,     inf,    inf,     2.737,   33.59,  415.59, 151.85
           14,      3.111,   21.12,  711.79, 228.79,      1.556,   48.41,  310.51, 199.62,      6.222,    0.00,     inf,    inf,     3.111,   35.45,  424.09, 136.32
           15,      3.529,   15.04, 1070.84, 303.40,      1.765,   44.44,  362.41, 205.37,      7.059,    0.00,     inf,    inf,     3.529,   36.44,  442.00, 125.23
           16,      4.000,   20.59,  834.22, 208.56,      2.000,   43.93,  391.07, 195.53,      8.000,    0.00,     inf,    inf,     4.000,   40.19,  427.48, 106.87
           17,      4.533,   19.46,  937.93, 206.90,      2.267,   41.89,  435.70, 192.22,      9.067,    0.00,     inf,    inf,     4.533,   39.57,  461.34, 101.77
           18,      5.143,   18.48, 1045.75, 203.34,      2.571,   39.15,  493.65, 191.98,     10.286,    0.00,     inf,    inf,     5.143,   42.20,  458.00,  89.06
           19,      5.846,   17.56, 1161.99, 198.76,      2.923,   36.45,  559.73, 191.49,     11.692,    0.00,     inf,    inf,     5.846,   47.26,  431.69,  73.84
           20,      6.667,   17.27, 1243.57, 186.54,      3.333,   35.42,  606.26, 181.88,     13.333,    0.00,     inf,    inf,     6.667,   49.88,  430.51,  64.58
           21,      7.636,   15.76, 1430.76, 187.36,      3.818,   33.51,  672.86, 176.23,     15.273,    0.00,     inf,    inf,     7.636,   49.44,  456.09,  59.73
           22,      8.800,   15.32, 1542.01, 175.23,      4.400,   31.77,  743.55, 168.99,     17.600,    0.00,     inf,    inf,     8.800,   50.81,  464.89,  52.83
           23,     10.222,   13.47, 1833.20, 179.33,      5.111,   31.30,  789.02, 154.37,     20.444,    0.00,     inf,    inf,    10.222,   49.46,  499.31,  48.85
           24,     12.000,   11.19, 2303.48, 191.96,      6.000,   26.42,  975.50, 162.58,     24.000,    0.00,     inf,    inf,    12.000,   49.54,  520.14,  43.34
           25,     14.286,   12.92, 2077.63, 145.43,      7.143,   25.24, 1063.65, 148.91,     28.571,    0.00,     inf,    inf,    14.286,   49.95,  537.37,  37.62
           26,     17.333,   11.49, 2430.14, 140.20,      8.667,   27.63, 1010.33, 116.58,     34.667,    0.00,     inf,    inf,    17.333,   50.52,  552.65,  31.88
           27,     21.600,   10.71, 2706.92, 125.32,     10.800,   28.39, 1021.33,  94.57,     43.200,    0.00,     inf,    inf,    21.600,   52.72,  549.90,  25.46
           28,     28.000,   13.65, 2202.43,  78.66,     14.000,   27.42, 1096.26,  78.30,     56.000,    0.00,     inf,    inf,    28.000,   50.11,  599.97,  21.43
           29,     38.667,    9.58, 3248.79,  84.02,     19.333,   27.54, 1130.52,  58.48,     77.333,    0.00,     inf,    inf,    38.667,   51.52,  604.41,  15.63
           30,     60.000,   12.22, 2636.03,  43.93,     30.000,   26.20, 1229.61,  40.99,    120.000,    0.00,     inf,    inf,    60.000,   54.64,  589.55,   9.83
           31,    124.000,    9.67, 3442.17,  27.76,     62.000,   28.33, 1174.94,  18.95,    248.000,    0.00,     inf,    inf,   124.000,   54.24,  613.67,   4.95
           32,        inf,   11.63, 2953.73,   0.00,        inf,   30.08, 1142.37,   0.00,        inf,    0.00,     inf,   -nan,       inf,   54.74,  627.74,   0.00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Voila! 1.1 TFLops くらい出ました!
(倍精度 off だと 250 GFlops くらい)

NVIDIA Tesla k20Xm 程度の性能が出ているのを確認できます.

4 枚挿したら 4.5 TFlops くらいの性能得られますね(P100 相当)

その他

調達した個体では

WARNING: infoROM is corrupted at gpu 0000:01:00.0

という warning が出ます.

NVIDIA GPU で infoROM is corrupted at gpu ワーニングのメモ
https://qiita.com/syoyo/items/f562e998f3cb7d30f44a

とりあえず無視でよさそう.

ECC

Titan 系(Titan V 含む)は ECC 対応ではありません.
したがってたまに計算が化ける可能性があります.

A6000 など Ampere 系 Quadro 相当だと ECC 対応していますが, 倍精度は弱いです.

倍精度つよめで ECC 対応が欲しい場合, 現状は Tesla シリーズのみになります.

K80 がコスパよいでしょうが, Tesla P100 16GB が eBay で各種費用入れて 20 万円くらいなので, P100 という手もあるでしょうか.

TODO

  • eBay で K80(倍精度 1.5 x 2 = 3 Tflops ある)が 4~5 万円で売っているので K80 も試してみる(K80 = sm_37 はまだギリギリ CUDA11 サポートあるっぽい?)
  • GTX TITAN でアプリが本当に倍精度性能がネックかどうか確認し, 倍精度がネックであれば TITAN V など調達を考える
2
1
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
2
1