unknownBrain commited on
Commit
0387745
·
verified ·
1 Parent(s): fedc988

Laptop auto-tuning: dynamic worker thread detection and expanded path candidates

Browse files
CMTLNet_complete_codebase_bundle.zip CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e386c80f14bb8e0965e984b5582a81c9271feeb2b5a82cae86ffa13c1215efea
3
- size 25745375
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1a0e90bea6100c7b2ea4275d237dd6cd21a1e987786991d22e9c1bc828662fb
3
+ size 25745459
code/config.py CHANGED
@@ -1,14 +1,16 @@
 
1
  import torch
2
 
3
  # Check if CUDA (GPU) is available and set the device accordingly
4
  use_cuda = torch.cuda.is_available()
5
  device = torch.device("cuda" if use_cuda else "cpu")
6
 
7
- # Number of worker threads for data loading
8
- n_threads = 12
 
9
 
10
  # Number of processes for multiprocessing (if applicable)
11
- num_processes = 12
12
 
13
  # Base batch size for training each individual task.
14
  # For each task, we apply oversampling by selecting one sample with label 0 and one sample with label 1 per batch.
 
1
+ import os
2
  import torch
3
 
4
  # Check if CUDA (GPU) is available and set the device accordingly
5
  use_cuda = torch.cuda.is_available()
6
  device = torch.device("cuda" if use_cuda else "cpu")
7
 
8
+ # Number of worker threads for data loading (safe auto-detection for laptop/server)
9
+ _cpu_avail = os.cpu_count() or 4
10
+ n_threads = 4 if (os.name == 'nt' or _cpu_avail <= 8) else 12
11
 
12
  # Number of processes for multiprocessing (if applicable)
13
+ num_processes = n_threads
14
 
15
  # Base batch size for training each individual task.
16
  # For each task, we apply oversampling by selecting one sample with label 0 and one sample with label 1 per batch.
code/dataLoder/dataload_utils.py CHANGED
@@ -234,6 +234,9 @@ def resolve_patient_path(path):
234
  os.path.join('data', 'ucsf_preprocess', pat_id),
235
  os.path.join('..', 'data', 'ucsf_preprocess', pat_id),
236
  os.path.join('..', '..', 'data', 'ucsf_preprocess', pat_id),
 
 
 
237
  os.path.join('UCSF-PDGM-v5-preprocessed', pat_id),
238
  os.path.join('D:\\jainam\\UCSF-PDGM-v5-preprocessed', pat_id),
239
  os.path.join(r'D:\jainam\UCSF-PDGM-v5-preprocessed', pat_id) if os.name == 'nt' else '',
 
234
  os.path.join('data', 'ucsf_preprocess', pat_id),
235
  os.path.join('..', 'data', 'ucsf_preprocess', pat_id),
236
  os.path.join('..', '..', 'data', 'ucsf_preprocess', pat_id),
237
+ os.path.join('ucsf_preprocess', pat_id),
238
+ os.path.join('..', 'ucsf_preprocess', pat_id),
239
+ os.path.join('..', '..', 'ucsf_preprocess', pat_id),
240
  os.path.join('UCSF-PDGM-v5-preprocessed', pat_id),
241
  os.path.join('D:\\jainam\\UCSF-PDGM-v5-preprocessed', pat_id),
242
  os.path.join(r'D:\jainam\UCSF-PDGM-v5-preprocessed', pat_id) if os.name == 'nt' else '',