Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11章のassortionerror発生について  #23

Open
biomania2021 opened this issue Oct 28, 2022 · 6 comments
Open

11章のassortionerror発生について  #23

biomania2021 opened this issue Oct 28, 2022 · 6 comments

Comments

@biomania2021
Copy link

11章の11.2のプログラムの実行方法及び、11.7の訓練の実施において
どちらも実行後にassortionerrorが出て進むことができずにおります。
こちらの11章の質問などを参考にして多数実行しましたが解決できないため
誠に申し訳ありませんがこちらに質問させていただくことになりました。

現在の私のPC等環境
PCスペック
プロセッサー:Intel Corei7-9700K CPU @ 3.60Ghz * 8
グラフィック NVIDIA Corporation GP106[GeForce GTX 1060 6Gb]
メモリ 16Gb
OS:Ubuntu22.04.1LTS 64ビット
GNOMEバージョン 42.4

使用環境
GoogleColaboratory
googledriveに必要データ等保存し、マウントして実行
ネット環境はフレッツ光なので通信速度は問題ないと思われます。

実行過程(以下をgoogle colabで実行)

googleドライブのgoogle colabへのマウント

from google.colab import drive
drive.mount('/content/drive')

カレントデイレクトリの移動

import os
_colab_dir = /content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/
os.chdir(_colab_dir)
実行結果
カレントワーキングディレクトリは[/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja]です

requirements.txtに書かれてた必要ライブラリ等のインストール

!pip install blosc
!pip install jupyter
!pip install SimpleITK
!pip install diskcache
!pip install cassandra-driver

キャッシュの事前準備のためp2ch11.prepcacheの実行

!python -m p2ch11.prepcache
実行結果
2022-10-24 06:41:13,508 INFO pid:385 main:043:main Starting LunaPrepCacheApp, Namespace(batch_size=1024, num_workers=2)
2022-10-24 06:41:16,716 INFO pid:385 p2ch11.dsets:185:init : 0 training samples
2022-10-24 06:41:16,716 WARNING pid:385 util.util:221:enumerateWithEstimate Stuffing cache ----/0, starting
2022-10-24 06:41:17,417 WARNING pid:385 util.util:252:enumerateWithEstimate Stuffing cache ----/0, done at 2022-10-24 06:41:17

プログラムの実行結果の実行

import datetime

from util.util import importstr
from util.logconf import logging
log = logging.getLogger('nb')

def run(app, *argv):
argv = list(argv)
argv.insert(0, '--num-workers=4') #
log.info(Running: {}({!r}).main().format(app, argv))

app_cls = importstr(*app.rsplit('.', 1))  # 
app_cls(argv).main()

[log.info](http://log.info/)(Finished: {}.{!r}).main().format(app, argv))

run('p2ch11.training.LunaTrainingApp', '--epochs=1')

実行結果
AssertionError Traceback (most recent call last)
in
15 log.info(Finished: {}.{!r}).main().format(app, argv))
16
---> 17 run('p2ch11.training.LunaTrainingApp', '--epochs=1')
18
19

3 frames
/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py in init(self, val_stride, isValSet_bool, series_uid, sortby_str)
169 elif val_stride > 0:
170 del self.candidateInfo_list[::val_stride]
--> 171 assert self.candidateInfo_list
172
173 if sortby_str == 'random':

AssertionError:

p2ch11.trainingの実行

!python -m p2ch11.training
実行結果
2022-10-24 06:42:10,608 INFO pid:486 main:079:initModel Using CUDA; 1 devices.
2022-10-24 06:42:12,257 INFO pid:486 main:138:main Starting LunaTrainingApp, Namespace(batch_size=32, comment='dwlpt', epochs=1, num_workers=2, tb_prefix='p2ch11')
Traceback (most recent call last):
File /usr/lib/python3.7/runpy.py, line 193, in _run_module_as_main
main, mod_spec)
File /usr/lib/python3.7/runpy.py, line 85, in _run_code
exec(code, run_globals)
File /content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py, line 387, in
LunaTrainingApp().main()
File /content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py, line 140, in main
train_dl = self.initTrainDl()
File /content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py, line 92, in initTrainDl
isValSet_bool=False,
File /content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py, line 171, in init
assert self.candidateInfo_list
AssertionError

以上のように、assertionErrorの発生のため実行できずにおります。
prepcacheを実行しているのにキャッシュを作成しているはず?なのにエラーが解消しないため、ここから進めずpytorchの理解と今後の導入ができず困っております。もしできますならばエラーの解消法をご教授いただきたく存じます。また、この場合にキャッシュの作成について具体的かつ有効な作成法がありましたら、申し訳ありませんが例などを示していただけると非常に有り難いです。

よろしくお願いいたします。
それでは失礼しました。

@Gin5050
Copy link
Owner

Gin5050 commented Oct 29, 2022

biomania2021様

ご質問いただきありがとうございます。
詳細な情報提供ありがとうございます

以下の実行結果を見るにキャッシュを作成するためのデータが存在していないようです

2022-10-24 06:41:16,716 INFO pid:385 p2ch11.dsets:185:init : 0 training samples

元データの取得と解凍がうまくいっていない可能性があります。データの配置等を確認いただくことは可能でしょうか。うまくいくと以下のような表記になります。

2022-10-29 04:57:27,994 INFO pid:76 p2ch11.dsets:186:init <p2ch11.dsets.LunaDataset object at 0x7f4d2c0d78d0>: 56938 training samples

@biomania2021
Copy link
Author

biomania2021 commented Nov 10, 2022

GIn5050様
回答ありがとうございました。
元データの配置は問題ありませんでしたがエラーが解消しませんでしたので、
データを再度解凍して上書きしたところ下記のように実行完了しました。
!python -m p2ch11.prepcache
2022-11-09 16:02:04,253 INFO pid:375 main:043:main Starting LunaPrepCacheApp, Namespace(batch_size=1024, num_workers=2)
2022-11-09 16:02:16,428 INFO pid:375 p2ch11.dsets:185:init <p2ch11.dsets.LunaDataset object at 0x7fb8299f8090>: 551065 training samples
2022-11-09 16:02:16,428 WARNING pid:375 util.util:221:enumerateWithEstimate Stuffing cache ----/539, starting
2022-11-09 16:11:09,523 INFO pid:375 util.util:241:enumerateWithEstimate Stuffing cache 16/539, done at 2022-11-09 20:09:57, 4:05:39
2022-11-09 16:33:51,872 INFO pid:375 util.util:241:enumerateWithEstimate Stuffing cache 64/539, done at 2022-11-09 20:16:19, 4:12:01
2022-11-09 18:20:26,297 INFO pid:375 util.util:241:enumerateWithEstimate Stuffing cache 256/539, done at 2022-11-09 20:50:59, 4:46:41
2022-11-09 21:13:07,430 WARNING pid:375 util.util:252:enumerateWithEstimate Stuffing cache ----/539, done at 2022-11-09 21:13:07

precacheについて、解決に的確なアドバイスいただきありがとうございました。

ただ、続く
import datetime

from util.util import importstr
from util.logconf import logging
log = logging.getLogger('nb')

def run(app, *argv):
argv = list(argv)
argv.insert(0, '--num-workers=4') # <1>
log.info("Running: {}({!r}).main()".format(app, argv))

app_cls = importstr(*app.rsplit('.', 1))  # <2>
app_cls(argv).main()

log.info("Finished: {}.{!r}).main()".format(app, argv))

run('p2ch11.training.LunaTrainingApp', '--epochs=1')
処理を実行したところ、

実行結果
2022-11-09 21:13:18,304 INFO pid:73 nb:010:run Running: p2ch11.training.LunaTrainingApp(['--num-workers=4', '--epochs=1']).main()
2022-11-09 21:13:30,468 INFO pid:73 p2ch11.training:138:main Starting LunaTrainingApp, Namespace(batch_size=32, comment='dwlpt', epochs=1, num_workers=4, tb_prefix='p2ch11')
2022-11-09 21:13:38,137 INFO pid:73 p2ch11.dsets:185:init <p2ch11.dsets.LunaDataset object at 0x7f1cda1da110>: 495958 training samples
/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:566: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
cpuset_checked))
2022-11-09 21:13:38,216 INFO pid:73 p2ch11.dsets:185:init <p2ch11.dsets.LunaDataset object at 0x7f1c5a49b790>: 55107 validation samples
2022-11-09 21:13:38,218 INFO pid:73 p2ch11.training:151:main Epoch 1 of 1, 15499/1723 batches of size 32*1
2022-11-09 21:13:38,229 WARNING pid:73 util.util:221:enumerateWithEstimate E1 Training ----/15499, starting
2022-11-09 21:14:52,541 INFO pid:73 util.util:241:enumerateWithEstimate E1 Training 16/15499, done at 2022-11-10 14:28:41, 17:14:40
2022-11-09 21:18:17,884 INFO pid:73 util.util:241:enumerateWithEstimate E1 Training 64/15499, done at 2022-11-10 15:23:51, 18:09:50
2022-11-09 21:32:18,176 INFO pid:73 util.util:241:enumerateWithEstimate E1 Training 256/15499, done at 2022-11-10 15:54:30, 18:40:29
2022-11-09 22:32:01,755 INFO pid:73 util.util:241:enumerateWithEstimate E1 Training 1024/15499, done at 2022-11-10 16:58:05, 19:44:04
2022-11-10 02:22:43,680 INFO pid:73 util.util:241:enumerateWithEstimate E1 Training 4096/15499, done at 2022-11-10 16:42:44, 19:28:43

IndexError Traceback (most recent call last)
in
15 log.info("Finished: {}.{!r}).main()".format(app, argv))
16
---> 17 run('p2ch11.training.LunaTrainingApp', '--epochs=1')

7 frames
in run(app, *argv)
11
12 app_cls = importstr(*app.rsplit('.', 1)) # <2>
---> 13 app_cls(argv).main()
14
15 log.info("Finished: {}.{!r}).main()".format(app, argv))

/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py in main(self)
152 ))
153
--> 154 trnMetrics_t = self.doTraining(epoch_ndx, train_dl)
155 self.logMetrics(epoch_ndx, 'trn', trnMetrics_t)
156

/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py in doTraining(self, epoch_ndx, train_dl)
176 start_ndx=train_dl.num_workers,
177 )
--> 178 for batch_ndx, batch_tup in batch_iter:
179 self.optimizer.zero_grad()
180

/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/util/util.py in enumerateWithEstimate(iter, desc_str, start_ndx, print_ndx, backoff, iter_len)
222 ))
223 start_ts = time.time()
--> 224 for (current_ndx, item) in enumerate(iter):
225 yield (current_ndx, item)
226 if current_ndx == print_ndx:

/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py in next(self)
679 # TODO(pytorch/pytorch#76750)
680 self._reset() # type: ignore[call-arg]
--> 681 data = self._next_data()
682 self._num_yielded += 1
683 if self._dataset_kind == _DatasetKind.Iterable and \

/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py in _next_data(self)
1374 else:
1375 del self._task_info[idx]
-> 1376 return self._process_data(data)
1377
1378 def _try_put_index(self):

/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py in _process_data(self, data)
1400 self._try_put_index()
1401 if isinstance(data, ExceptionWrapper):
-> 1402 data.reraise()
1403 return data
1404

/usr/local/lib/python3.7/dist-packages/torch/_utils.py in reraise(self)
459 # instantiate since we don't know how to
460 raise RuntimeError(msg) from None
--> 461 raise exception
462
463

IndexError: Caught IndexError in DataLoader worker process 3.
Original Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 198, in getitem
width_irc,
File "/usr/local/lib/python3.7/dist-packages/diskcache/core.py", line 1877, in wrapper
result = func(*args, **kwargs)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 146, in getCtRawCandidate
ct = getCt(series_uid)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 142, in getCt
return Ct(series_uid)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 88, in init
)[0]
IndexError: list index out of range
のエラーが発生しました。

同じく、!python -m p2ch11.trainingの実行においても、

2022-11-10 06:57:43,307 INFO pid:1073 main:138:main Starting LunaTrainingApp, Namespace(batch_size=32, comment='dwlpt', epochs=1, num_workers=2, tb_prefix='p2ch11')
2022-11-10 06:57:56,800 INFO pid:1073 p2ch11.dsets:185:init <p2ch11.dsets.LunaDataset object at 0x7f1518850ad0>: 495958 training samples
2022-11-10 06:57:56,865 INFO pid:1073 p2ch11.dsets:185:init <p2ch11.dsets.LunaDataset object at 0x7f1506c4c990>: 55107 validation samples
2022-11-10 06:57:56,865 INFO pid:1073 main:151:main Epoch 1 of 1, 15499/1723 batches of size 32*1
2022-11-10 06:57:56,868 WARNING pid:1073 util.util:221:enumerateWithEstimate E1 Training ----/15499, starting
2022-11-10 07:00:01,771 INFO pid:1073 util.util:241:enumerateWithEstimate E1 Training 16/15499, done at 2022-11-11 12:36:09, 1 day, 5:37:50
2022-11-10 07:04:06,920 INFO pid:1073 util.util:241:enumerateWithEstimate E1 Training 64/15499, done at 2022-11-11 06:46:39, 23:48:20
2022-11-10 07:18:39,109 INFO pid:1073 util.util:241:enumerateWithEstimate E1 Training 256/15499, done at 2022-11-11 03:34:36, 20:36:18
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py", line 387, in
LunaTrainingApp().main()
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py", line 154, in main
trnMetrics_t = self.doTraining(epoch_ndx, train_dl)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py", line 178, in doTraining
for batch_ndx, batch_tup in batch_iter:
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/util/util.py", line 224, in enumerateWithEstimate
for (current_ndx, item) in enumerate(iter):
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 681, in next
data = self._next_data()
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1376, in _next_data
return self._process_data(data)
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1402, in _process_data
data.reraise()
File "/usr/local/lib/python3.7/dist-packages/torch/_utils.py", line 461, in reraise
raise exception
IndexError: Caught IndexError in DataLoader worker process 1.
Original Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 198, in getitem
width_irc,
File "/usr/local/lib/python3.7/dist-packages/diskcache/core.py", line 1877, in wrapper
result = func(*args, **kwargs)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 146, in getCtRawCandidate
ct = getCt(series_uid)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 142, in getCt
return Ct(series_uid)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 88, in init
)[0]
IndexError: list index out of range
のエラーが発生して実行を完了することができませんでした。
これらの解決法はありますでしょうか。
もしありましたらアドバイスいただけると有り難いです。

また現在GoogleColaboratoryでこれらをPROバージョンで実行しておりますが、
GPU利用(標準)で実行した場合では、ディスクが最大166Gbまでとなっており、
precache実行でsubset0〜9までを使用すると途中でディスク容量がいっぱいになり
処理が止まってしまいますが、これはsubesetの数を減らして実行するもしくはGPU搭載PC等を環境を用意して実行するしかないのでしょうか?こちらも回答いただけるとありがたいです。

@Gin5050
Copy link
Owner

Gin5050 commented Nov 13, 2022

biomania2021様

まずエラーに関してですが、何らかの原因で参照先のデータを読み取れていないように見えます。
現状以下のようにデータは存在しておりますでしょうか
image

GPU利用(標準)で実行した場合では、ディスクが最大166Gbまでとなっており、
precache実行でsubset0〜9までを使用すると途中でディスク容量がいっぱいになり
処理が止まってしまいますが、これはsubesetの数を減らして実行するもしくはGPU搭載PC等を環境を用意して実行するしかないのでしょうか?

こちら大変申し訳ないのですが、ご推察の通りcolabではディスク容量に引っ掛かり全subsetを使用する場合は実行が困難です。
お書きいただいたように全データ実行するには、ローカルで必要スペックを満たすマシンを用意するかクラウド上でVMを用意する必要があります。

@biomania2021
Copy link
Author

biomania2021 commented Nov 14, 2022

GIn5050様
回答ありがとうございました。
ご指摘の件ですが、
データの配置については、googleドライブ内に
/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/data-unversioned/part2/luna/
の以下にsubset0などが格納されており、それぞれには.mhdファイルと.rawファイルが格納されていることを確認いたしました。

また、もう一つの回答をいただいた件からgoogle colabのディスク限界に対応するため、subsetを0,1,2,3,4のみとしてキャッシュを作成(成功)して再度下記をGPU標準の設定で
import datetime

from util.util import importstr
from util.logconf import logging
log = logging.getLogger('nb')

def run(app, *argv):
argv = list(argv)
argv.insert(0, '--num-workers=4') # <1>
log.info("Running: {}({!r}).main()".format(app, argv))

app_cls = importstr(*app.rsplit('.', 1)) # <2>
app_cls(argv).main()

log.info("Finished: {}.{!r}).main()".format(app, argv))
run('p2ch11.training.LunaTrainingApp', '--epochs=1')
処理を再度実行したところ、

2022-11-14 08:37:57,323 INFO pid:1084 nb:011:run Running: p2ch11.training.LunaTrainingApp(['--num-workers=4', '--epochs=1']).main()
2022-11-14 08:38:07,183 INFO pid:1084 p2ch11.training:079:initModel Using CUDA; 1 devices.
2022-11-14 08:38:11,425 INFO pid:1084 p2ch11.training:138:main Starting LunaTrainingApp, Namespace(batch_size=32, comment='dwlpt', epochs=1, num_workers=4, tb_prefix='p2ch11')
2022-11-14 08:38:15,675 INFO pid:1084 p2ch11.dsets:185:init <p2ch11.dsets.LunaDataset object at 0x7fa164dda2d0>: 247822 training samples
/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:566: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
cpuset_checked))
2022-11-14 08:38:15,707 INFO pid:1084 p2ch11.dsets:185:init <p2ch11.dsets.LunaDataset object at 0x7fa16b311650>: 27536 validation samples
2022-11-14 08:38:15,709 INFO pid:1084 p2ch11.training:151:main Epoch 1 of 1, 7745/861 batches of size 32*1
2022-11-14 08:38:15,718 WARNING pid:1084 util.util:221:enumerateWithEstimate E1 Training ----/7745, starting
2022-11-14 08:38:32,180 INFO pid:1084 util.util:241:enumerateWithEstimate E1 Training 16/7745, done at 2022-11-14 09:27:12, 0:48:45
2022-11-14 08:38:56,011 INFO pid:1084 util.util:241:enumerateWithEstimate E1 Training 64/7745, done at 2022-11-14 09:39:14, 1:00:47
2022-11-14 08:40:26,494 INFO pid:1084 util.util:241:enumerateWithEstimate E1 Training 256/7745, done at 2022-11-14 09:39:15, 1:00:47
2022-11-14 08:46:09,660 INFO pid:1084 util.util:241:enumerateWithEstimate E1 Training 1024/7745, done at 2022-11-14 09:36:53, 0:58:25
2022-11-14 09:10:57,152 INFO pid:1084 util.util:241:enumerateWithEstimate E1 Training 4096/7745, done at 2022-11-14 09:39:55, 1:01:27
2022-11-14 09:45:23,266 WARNING pid:1084 util.util:252:enumerateWithEstimate E1 Training ----/7745, done at 2022-11-14 09:45:23
2022-11-14 09:45:31,817 INFO pid:1084 numexpr.utils:160:_init_num_threads NumExpr defaulting to 2 threads.
2022-11-14 09:45:32,549 INFO pid:1084 p2ch11.training:261:logMetrics E1 LunaTrainingApp
2022-11-14 09:45:32,700 INFO pid:1084 p2ch11.training:295:logMetrics E1 trn nan loss, 2.2% correct,
2022-11-14 09:45:32,702 INFO pid:1084 p2ch11.training:306:logMetrics E1 trn_neg nan loss, 1.9% correct (4775 of 247174)
2022-11-14 09:45:32,705 INFO pid:1084 p2ch11.training:317:logMetrics E1 trn_pos nan loss, 98.9% correct (641 of 648)
2022-11-14 09:45:35,014 WARNING pid:1084 util.util:221:enumerateWithEstimate E1 Validation ----/861, starting
/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:566: UserWarning: This DataLoader will create 4 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary.
cpuset_checked))
2022-11-14 09:45:51,626 INFO pid:1084 util.util:241:enumerateWithEstimate E1 Validation 16/861, done at 2022-11-14 10:00:17, 0:14:39
2022-11-14 09:46:20,842 INFO pid:1084 util.util:241:enumerateWithEstimate E1 Validation 64/861, done at 2022-11-14 09:55:36, 0:09:57
2022-11-14 09:48:58,112 INFO pid:1084 util.util:241:enumerateWithEstimate E1 Validation 256/861, done at 2022-11-14 09:56:55, 0:11:16
2022-11-14 09:55:50,472 WARNING pid:1084 util.util:252:enumerateWithEstimate E1 Validation ----/861, done at 2022-11-14 09:55:50
2022-11-14 09:55:50,476 INFO pid:1084 p2ch11.training:261:logMetrics E1 LunaTrainingApp
2022-11-14 09:55:50,639 INFO pid:1084 p2ch11.training:295:logMetrics E1 val nan loss, 0.3% correct,
2022-11-14 09:55:50,641 INFO pid:1084 p2ch11.training:306:logMetrics E1 val_neg nan loss, 0.0% correct (0 of 27463)
2022-11-14 09:55:50,647 INFO pid:1084 p2ch11.training:317:logMetrics E1 val_pos nan loss, 100.0% correct (73 of 73)
2022-11-14 09:55:50,733 INFO pid:1084 nb:016:run Finished: p2ch11.training.LunaTrainingApp.['--num-workers=4', '--epochs=1']).main()
となり。これらの処理はエラー発生なく実行されたと思われました。

ただ、続く
!python -m p2ch11.trainingの実行では、

2022-11-14 09:56:01,788 INFO pid:1994 main:079:initModel Using CUDA; 1 devices.
2022-11-14 09:56:06,349 INFO pid:1994 main:138:main Starting LunaTrainingApp, Namespace(batch_size=32, comment='dwlpt', epochs=1, num_workers=2, tb_prefix='p2ch11')
2022-11-14 09:56:10,800 INFO pid:1994 p2ch11.dsets:185:init <p2ch11.dsets.LunaDataset object at 0x7fb018f2cfd0>: 247822 training samples
2022-11-14 09:56:10,848 INFO pid:1994 p2ch11.dsets:185:init <p2ch11.dsets.LunaDataset object at 0x7fb00777f790>: 27536 validation samples
2022-11-14 09:56:10,849 INFO pid:1994 main:151:main Epoch 1 of 1, 7745/861 batches of size 32*1
2022-11-14 09:56:10,853 WARNING pid:1994 util.util:221:enumerateWithEstimate E1 Training ----/7745, starting
2022-11-14 09:56:34,704 INFO pid:1994 util.util:241:enumerateWithEstimate E1 Training 16/7745, done at 2022-11-14 11:44:04, 1:47:41
2022-11-14 09:57:22,506 INFO pid:1994 util.util:241:enumerateWithEstimate E1 Training 64/7745, done at 2022-11-14 11:59:55, 2:03:33
2022-11-14 10:00:26,075 INFO pid:1994 util.util:241:enumerateWithEstimate E1 Training 256/7745, done at 2022-11-14 11:59:47, 2:03:25
2022-11-14 10:16:04,536 INFO pid:1994 util.util:241:enumerateWithEstimate E1 Training 1024/7745, done at 2022-11-14 12:25:31, 2:29:09
2022-11-14 11:36:40,258 INFO pid:1994 util.util:241:enumerateWithEstimate E1 Training 4096/7745, done at 2022-11-14 13:06:01, 3:09:39
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py", line 387, in
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py", line 154, in main
trnMetrics_t = self.doTraining(epoch_ndx, train_dl)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/training.py", line 178, in doTraining
for batch_ndx, batch_tup in batch_iter:
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/util/util.py", line 224, in enumerateWithEstimate
for (current_ndx, item) in enumerate(iter):
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 681, in next
data = self._next_data()
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1376, in _next_data
return self._process_data(data)
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py", line 1402, in _process_data
data.reraise()
File "/usr/local/lib/python3.7/dist-packages/torch/_utils.py", line 461, in reraise
raise exception
IndexError: Caught IndexError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/usr/local/lib/python3.7/dist-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 198, in getitem
File "/usr/local/lib/python3.7/dist-packages/diskcache/core.py", line 1877, in wrapper
result = func(*args, **kwargs)
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 146, in getCtRawCandidate
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 142, in getCt
File "/content/drive/MyDrive/pytorch/deep-learning-with-pytorch-ja/p2ch11/dsets.py", line 88, in init
IndexError: list index out of range

とのように、前回と同様のエラーが生じておりました。
現在google colabはPRO+にしておりバックグラウンド処理可能となっておりますが、
今回の処理はPC起動のまま処理させております。

ご多忙な中お手数取らせてしまい誠に申し訳ありませんが、
エラー解決の方法ありましたら宜しくお願い致します。

@Gin5050
Copy link
Owner

Gin5050 commented Nov 26, 2022

biomania2021 様

回答が遅くなり大変申し訳ございません。
まず一度状況の整理をさせてください

現在、biomania2021 様が実施されている処理は本書の11.7(P372)記載の内容だと理解してます。
そして、python -m p2ch11.trainingのコマンドをp2_run_everything.ipynbから実行されていると推測します。

上記の条件のもとsubset0のみを用いた場合ですと、正常に実行が終わることを確認しました。
お手数ではありますが、問題の切り分けのために一度subset0のみの場合で実行が完了するか試していただくことは可能でしょうか?

よろしくお願いいたします

@biomania2021
Copy link
Author

GIn5050様
回答ありがとうございました。

ご回答のとおり、subset0のみにして実行したところ正常に実行が終了しました。
また同様にsubset0,1,2,3を使用して同様の処理を行ったところ、正常に終了することができました。subset0〜4より多く使用した場合はgoogle colab PRO+上のディスク使用量はまだ余裕はあるように見えるものの、前回と同様にIndexError: list index out of rangeもしくはOSError: [Errno 28] No space left on deviceが発生することが確認できましたので、この条件で学習を続けていきたいと思います。

この度はgoogle colabを使用して実行しておりましたが、より安定かつ大容量のデータの解析を行うべく以前にお教えいただいたとおり、コストはある程度覚悟する必要がありますがローカルで実行可能なマシン構築もしくはクラウド上でVMの使用を検討したいと思います。

ご多忙な中お手数掛けまして申し訳ありませんでした。
多くの的確なアドバイス感謝致します。
それでは失礼しました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants