Project-MONAI / Project-MONAI/tutorials

fork vs spawn on MacOS Python 3.9 error

Đang mở
#625 13 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement
Ngôn ngữ chính
Jupyter Notebook
Star
2.5k
Fork
803
Merge trung bình
6 ngày 22 giờ
Pull request đã merge (30 ngày)
3

Mô tả

Hi all,

I'm running macos conda-forge on the M1 architecture and testing the mednist_tutorial.ipynb and other jupyter notebooks. I get the following error

  File "/opt/homebrew/Caskroom/miniforge/base/envs/pytorch_env/lib/python3.9/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/pytorch_env/lib/python3.9/multiprocessing/spawn.py", line 126, in _main
    self = reduction.pickle.load(from_parent)
AttributeError: Can't get attribute 'MedNISTDataset' on <module '__main__' (built-in)>

This seems to be caused by spawn which apparently became default by Python 3.8 and later. It is fixed by adding the argument multiprocessing_context="fork" to calls of torch.utils.data.DataLoader, however, I suggest that a deeper fixed is made for non-experts.

Steps to reproduce the behavior
On MacOS/python-forge
2. jupyter lab mednist_tutorial.ipynb
3. press the clear kernel and run all button

Expected behavior
A demo network should be set up and trained

Environment

% python --version
Python 3.9.10
% python -c 'import monai; monai.config.print_debug_info()'

================================
Printing MONAI config...
================================
MONAI version: 0.9.dev2210
Numpy version: 1.22.3
Pytorch version: 1.10.2
MONAI flags: HAS_EXT = False, USE_COMPILED = False
MONAI rev id: 1a660e6a7a50e985af5ff76b559baab44175438c
MONAI __file__: /opt/homebrew/Caskroom/miniforge/base/envs/pytorch_env/lib/python3.9/site-packages/monai/__init__.py

Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: NOT INSTALLED or UNKNOWN VERSION.
scikit-image version: NOT INSTALLED or UNKNOWN VERSION.
Pillow version: 9.0.1
Tensorboard version: 2.8.0
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: NOT INSTALLED or UNKNOWN VERSION.
tqdm version: 4.63.0
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: NOT INSTALLED or UNKNOWN VERSION.
pandas version: NOT INSTALLED or UNKNOWN VERSION.
einops version: 0.4.1
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: NOT INSTALLED or UNKNOWN VERSION.

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies


================================
Printing system config...
================================
`psutil` required for `print_system_info`

================================
Printing GPU config...
================================
Num GPUs: 0
Has CUDA: False
cuDNN enabled: False

Thank you for a nice package, Jon

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với mednist_tutorial.ipynb trong Jupyter Lab trên macOS với Python 3.9, tái hiện lỗi bằng cách xóa kernel và chạy tất cả, sau đó kiểm tra các lệnh gọi torch.utils.data.DataLoader trong notebook. Công việc được xem là hoàn tất khi có thể thiết lập và huấn luyện mạng demo mà không gặp lỗi multiprocessing của MedNISTDataset.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
jupyter-notebook, python, pytorch
Lĩnh vực
machine-learning
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.