CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/compute/nvidia.tsx
Views: 687
1
import { GPU_SPECS } from "@cocalc/util/compute/gpu-specs";
2
import { commas, plural } from "@cocalc/util/misc";
3
import { Popover, Table } from "antd";
4
import { Icon } from "@cocalc/frontend/components/icon";
5
import { A } from "@cocalc/frontend/components/A";
6
7
export default function NVIDIA({
8
gpu,
9
count,
10
}: {
11
gpu: keyof typeof GPU_SPECS;
12
count: number;
13
}) {
14
const spec = GPU_SPECS[gpu];
15
return (
16
<Popover
17
title={
18
<div style={{ fontSize: "13pt" }}>
19
{spec != null && (
20
<div style={{ float: "right" }}>
21
{
22
<A href={spec.datasheet}>
23
<Icon name="external-link" /> Datasheet
24
</A>
25
}
26
</div>
27
)}
28
<Icon name="gpu" style={{ marginRight: "5px", fontSize: "16pt" }} />
29
{count} NVIDIA {gpu} {plural(count, "GPU")}
30
</div>
31
}
32
content={
33
<div style={{ width: "500px" }}>
34
<GPUSpecs gpu={gpu} count={count} />
35
</div>
36
}
37
>
38
<span
39
style={{
40
cursor: "pointer",
41
}}
42
>
43
{count} × NVIDIA {gpu} {plural(count, "GPU")}
44
</span>
45
</Popover>
46
);
47
}
48
49
export function GPUSpecs({ gpu, count }) {
50
const spec = GPU_SPECS[gpu];
51
if (spec == null) {
52
console.warn({ gpu, GPU_SPECS });
53
return null;
54
}
55
const dataSource = [
56
{
57
key: "memory",
58
name: <b>GPU Memory</b>,
59
value: `${commas(count * spec.memory)} GB`,
60
per: `${commas(spec.memory)} GB`,
61
},
62
{
63
key: "memory_bw",
64
name: <b>Memory Bandwidth</b>,
65
per: `${commas(spec.memory_bw)} GB/s`,
66
},
67
];
68
if (spec.cuda_cores) {
69
dataSource.push({
70
key: "cuda_cores",
71
name: <b>CUDA cores</b>,
72
value: commas(count * spec.cuda_cores),
73
per: commas(spec.cuda_cores),
74
});
75
}
76
if (spec.tensor_cores) {
77
dataSource.push({
78
key: "tensor_cores",
79
name: <b>Tensor cores</b>,
80
value: commas(count * spec.tensor_cores),
81
per: commas(spec.tensor_cores),
82
});
83
}
84
85
const columns = [
86
{
87
title: "",
88
dataIndex: "name",
89
key: "name",
90
},
91
{
92
title: "Per GPU",
93
dataIndex: "per",
94
key: "per",
95
},
96
{
97
title: "Total",
98
dataIndex: "value",
99
key: "value",
100
},
101
];
102
return (
103
<div>
104
<Table pagination={false} dataSource={dataSource} columns={columns} />
105
</div>
106
);
107
}
108
109