Novartis / torchsurv

Deep survival analysis made easy
http://opensource.nibr.com/torchsurv/
MIT License
69 stars 7 forks source link

Tutorial dataset error on momentum.ipynb #50

Closed MasalaKimchi closed 2 months ago

MasalaKimchi commented 2 months ago

Hi, thank you for building this wonderful repository!

While trying to work on the docs/notebooks/momentum.ipynb

I encountered an error during downloading MNIST dataset in the 8th code block on Jupyter Notebook. I assume this error is not related to the package itself, but was not sure where to request help for it. If you can help, that would be greatly appreciated.

My environment is Windows, Python 3.11.9, PyTorch 2.4.0+cu121, and optional dependencies are correctly installed

This is the code-block where error arises:

torch.manual_seed(42)

# Load datamodule
datamodule = MNISTDataModule(batch_size=BATCH_SIZE, transforms=transforms)
datamodule.prepare_data()  # Download the data
datamodule.setup()  # Wrangle the data

# print image examples, with label
x, y = next(iter(datamodule.train_dataloader()))

plt.rcParams["figure.figsize"] = [13, 5]
for i in range(5):
    plt.subplot(1, 5, i + 1)
    plt.imshow(x[i].squeeze(), cmap="gray")
    plt.title(f"time: {y[i]}, event = 1")

The error seems to be related to the original link being in-accessible due to HTTP as shown in the error output below, "HTTP Error 403: Forbidden" for multiple links. While files are downloaded, the kernel crashes. when I re-run the jupyterNotebook the code continues to crash.

Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
Failed to download (trying next):
HTTP Error 403: Forbidden

Downloading https://ossci-datasets.s3.amazonaws.com/mnist/train-images-idx3-ubyte.gz
Downloading https://ossci-datasets.s3.amazonaws.com/mnist/train-images-idx3-ubyte.gz to [.\MNIST\raw\train-images-idx3-ubyte.gz](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw/train-images-idx3-ubyte.gz)
100%|██████████| 9912422/9912422 [00:00<00:00, 20185010.11it/s]
Extracting [.\MNIST\raw\train-images-idx3-ubyte.gz](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw/train-images-idx3-ubyte.gz) to [.\MNIST\raw](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw)

Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
Failed to download (trying next):
HTTP Error 403: Forbidden

Downloading https://ossci-datasets.s3.amazonaws.com/mnist/train-labels-idx1-ubyte.gz
Downloading https://ossci-datasets.s3.amazonaws.com/mnist/train-labels-idx1-ubyte.gz to [.\MNIST\raw\train-labels-idx1-ubyte.gz](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw/train-labels-idx1-ubyte.gz)
100%|██████████| 28881/28881 [00:00<00:00, 1522378.96it/s]
Extracting [.\MNIST\raw\train-labels-idx1-ubyte.gz](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw/train-labels-idx1-ubyte.gz) to [.\MNIST\raw](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw)

Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
Failed to download (trying next):
HTTP Error 403: Forbidden

Downloading https://ossci-datasets.s3.amazonaws.com/mnist/t10k-images-idx3-ubyte.gz
Downloading https://ossci-datasets.s3.amazonaws.com/mnist/t10k-images-idx3-ubyte.gz to [.\MNIST\raw\t10k-images-idx3-ubyte.gz](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw/t10k-images-idx3-ubyte.gz)
100%|██████████| 1648877/1648877 [00:00<00:00, 11683196.27it/s]
Extracting [.\MNIST\raw\t10k-images-idx3-ubyte.gz](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw/t10k-images-idx3-ubyte.gz) to [.\MNIST\raw](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw)

Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
Failed to download (trying next):
HTTP Error 403: Forbidden

Downloading https://ossci-datasets.s3.amazonaws.com/mnist/t10k-labels-idx1-ubyte.gz
Downloading https://ossci-datasets.s3.amazonaws.com/mnist/t10k-labels-idx1-ubyte.gz to [.\MNIST\raw\t10k-labels-idx1-ubyte.gz](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw/t10k-labels-idx1-ubyte.gz)
100%|██████████| 4542/4542 [00:00<00:00, 4548836.86it/s]
Extracting [.\MNIST\raw\t10k-labels-idx1-ubyte.gz](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw/t10k-labels-idx1-ubyte.gz) to [.\MNIST\raw](https://file+.vscode-resource.vscode-cdn.net/d%3A/xxx/CTCS_IRM/Data/CLARIFY_500/MNIST/raw)

The Kernel crashed while executing code in the current cell or a previous cell. 
Please review the code in the cell(s) to identify a possible cause of the failure. 
Click [here](https://aka.ms/vscodeJupyterKernelCrash) for more info. 
View Jupyter [log](command:jupyter.viewOutput) for further details.
tcoroller commented 2 months ago

Hi Justin! Thanks for the kind words, we have thrilled that you enjoy the package 🙂

I am on leave until end of September, but I will check it out when I am back, it may be related to your system. Did you check in another computer in the meantime?

Thanks!

qiancao commented 2 months ago

@MasalaKimchi Thank you for raising this issue request! I've just run the tutorial in a new conda environment without a kernel crash. I got the same HTTP issue, but the dataset was eventually downloaded from AWS.

Are you able to isolate the line where the crash occurs?

MasalaKimchi commented 2 months ago

@qiancao @tcoroller I hope you are having a wonderful weekend, and thanks for the prompt response.

Initially, when I was working on the momentum.ipynb the kernel crashed despite successful download of data. Strangely enough, I deleted the downloaded folder, restarted a computer, re-ran the code, and now it works like a charm!

I was unable to isolate the code block and reproduce the error. Perhaps, it was my personal computer setting that encountered a problem.

Thank you!