質問編集履歴
1
参考ソース追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,4 +6,25 @@
|
|
6
6
|
import cupy as np
|
7
7
|
np.cuda.set_allocator(np.cuda.MemoryPool().malloc)
|
8
8
|
np.add.at = np.scatter_add
|
9
|
+
```
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
[参考「ゼロから作るdeep learning 2」](https://github.com/oreilly-japan/deep-learning-from-scratch-2/blob/master/common/np.py)
|
14
|
+
|
15
|
+
```Python
|
16
|
+
# coding: utf-8
|
17
|
+
from common.config import GPU
|
18
|
+
|
19
|
+
|
20
|
+
if GPU:
|
21
|
+
import cupy as np
|
22
|
+
np.cuda.set_allocator(np.cuda.MemoryPool().malloc)
|
23
|
+
np.add.at = np.scatter_add
|
24
|
+
|
25
|
+
print('\033[92m' + '-' * 60 + '\033[0m')
|
26
|
+
print(' ' * 23 + '\033[92mGPU Mode (cupy)\033[0m')
|
27
|
+
print('\033[92m' + '-' * 60 + '\033[0m\n')
|
28
|
+
else:
|
29
|
+
import numpy as np
|
9
30
|
```
|