{
  "id": 391454,
  "title": "Colab keeps crashing when importing graphnet modules",
  "url": "/competitions/icecube-neutrinos-in-deep-ice/discussion/391454",
  "author_name": "Michael Barrett",
  "post_date": "2023-03-01T14:14:22.531000",
  "votes": 1,
  "comment_count": 4,
  "views": 0,
  "content": "<p>Has anybody any experience importing GraphNeT into Colab? It took me a few days to work out how to set everything up and I've finally got: </p>\n<p><code>from graphnet.data.constants import FEATURES, TRUTH</code></p>\n<p>…working. But then when I tried the following two (in both/either order):</p>\n<p><code>from graphnet.models import StandardModel</code><br>\n<code>from graphnet.models.gnn import DynEdge</code></p>\n<p>…I get \"Your session crashed for an unknown reason\" and the log doesn't appear to offer any useful information. I've already successfully run:</p>\n<p><code>!pip install -r requirements/torch_gpu.txt -e .[develop,torch]</code></p>\n<p>… so I assume I have the correct dependencies. I've also tried it with both GPU and CPU runtimes. Any suggestions?</p>",
  "messages": [
    {
      "id": 2166673,
      "postDate": "2023-03-02T23:13:42.870Z",
      "content": "<p>The notebook suddenly closing might be due to some weird version errors. In which case I'd try the following (note that I haven't tried it, so it has some - non-trivial - chance of failing):</p>\n<ul>\n<li>Restart the notebook completely (so we erase any bad imports)</li>\n<li>Make sure these are the 2 first commands that the notebook run (so put it in a cell at the top):</li>\n</ul>\n<pre><code>!pip install --force-reinstall -r /path/to/graphnet/directory/requirements/torch_cpu.txt\n!pip install /path/to/graphnet/directory\n</code></pre>\n<ul>\n<li>Test the imports:</li>\n</ul>\n<pre><code>import torch\nprint(torch.__version__)\nimport torch_geometric\nprint(torch_geometric.__version__)\nimport graphnet\nprint(graphnet.__file__)\n</code></pre>\n<p>For GPU, you might get some other problems, such as the CUDA version from graphnet not being the one installed in your environment. You can check the cuda version with <code>import torch; print(torch.cuda.version)</code> and install following instructions from the <a href=\"https://pytorch.org/get-started/previous-versions/\" target=\"_blank\">pytorch</a> and <a href=\"https://pytorch-geometric.readthedocs.io/en/2.0.4/notes/installation.html\" target=\"_blank\">pytorch-geometric</a> websites, try to match the version from the <a href=\"https://github.com/graphnet-team/graphnet/blob/main/requirements/torch_gpu.txt\" target=\"_blank\">graphnet requirements file</a> (for example, if cuda is 11.3, install torch 1.11.0 for cuda 11.3).</p>\n<p><code>--force-reinstall</code> might not be needed, I added just in case. You can add <code>--quiet</code> (after sorting all out) to silence pip.</p>\n<p>Cheers,<br>\nlts</p>\n<p>PS: It might be something related to memory too? So make sure you're not loading anything in the beginning, just get the imports right and only then start loading the files.</p>",
      "rawMarkdown": "The notebook suddenly closing might be due to some weird version errors. In which case I'd try the following (note that I haven't tried it, so it has some - non-trivial - chance of failing):\n\n- Restart the notebook completely (so we erase any bad imports)\n- Make sure these are the 2 first commands that the notebook run (so put it in a cell at the top):\n\n```\n!pip install --force-reinstall -r /path/to/graphnet/directory/requirements/torch_cpu.txt\n!pip install /path/to/graphnet/directory\n```\n\n- Test the imports:\n\n```\nimport torch\nprint(torch.__version__)\nimport torch_geometric\nprint(torch_geometric.__version__)\nimport graphnet\nprint(graphnet.__file__)\n```\n\nFor GPU, you might get some other problems, such as the CUDA version from graphnet not being the one installed in your environment. You can check the cuda version with `import torch; print(torch.cuda.version)` and install following instructions from the [pytorch](https://pytorch.org/get-started/previous-versions/) and [pytorch-geometric](https://pytorch-geometric.readthedocs.io/en/2.0.4/notes/installation.html) websites, try to match the version from the [graphnet requirements file](https://github.com/graphnet-team/graphnet/blob/main/requirements/torch_gpu.txt) (for example, if cuda is 11.3, install torch 1.11.0 for cuda 11.3).\n\n`--force-reinstall` might not be needed, I added just in case. You can add `--quiet` (after sorting all out) to silence pip.\n\nCheers,\nlts\n\nPS: It might be something related to memory too? So make sure you're not loading anything in the beginning, just get the imports right and only then start loading the files.",
      "votes": 1,
      "replies": [
        {
          "id": 2167616,
          "postDate": "2023-03-03T15:57:23.700Z",
          "content": "<p>Thanks for your help.</p>\n<p>The problem related to numerous issues including (but not limited to): my lack of experience with Conda (or any other) environments and some Colab related idiosynchracies, as well as torch-geometric taking minutes to download - but then an hour to build and install.</p>\n<p>IIRC, that particular module (from graphnet.data.constants import FEATURES, TRUTH) stopped crashing when I made sure I ran this first:</p>\n<p><code>!pip install colorlog</code></p>",
          "rawMarkdown": "Thanks for your help.\n\nThe problem related to numerous issues including (but not limited to): my lack of experience with Conda (or any other) environments and some Colab related idiosynchracies, as well as torch-geometric taking minutes to download - but then an hour to build and install.\n\nIIRC, that particular module (from graphnet.data.constants import FEATURES, TRUTH) stopped crashing when I made sure I ran this first:\n\n`!pip install colorlog`",
          "replies": [
            {
              "id": 2168054,
              "postDate": "2023-03-03T20:48:55.210Z",
              "content": "<p>Damn, I'm always sorry for people first coming into python package issues, it's always a f*cking mess haha In any case, good to know that you had your problem sorted, good luck in the competition !</p>",
              "rawMarkdown": "Damn, I'm always sorry for people first coming into python package issues, it's always a f*cking mess haha In any case, good to know that you had your problem sorted, good luck in the competition !",
              "votes": 1
            }
          ]
        }
      ]
    },
    {
      "id": 2164381,
      "postDate": "2023-03-01T14:14:22.530Z",
      "content": "<p>Has anybody any experience importing GraphNeT into Colab? It took me a few days to work out how to set everything up and I've finally got: </p>\n<p><code>from graphnet.data.constants import FEATURES, TRUTH</code></p>\n<p>…working. But then when I tried the following two (in both/either order):</p>\n<p><code>from graphnet.models import StandardModel</code><br>\n<code>from graphnet.models.gnn import DynEdge</code></p>\n<p>…I get \"Your session crashed for an unknown reason\" and the log doesn't appear to offer any useful information. I've already successfully run:</p>\n<p><code>!pip install -r requirements/torch_gpu.txt -e .[develop,torch]</code></p>\n<p>… so I assume I have the correct dependencies. I've also tried it with both GPU and CPU runtimes. Any suggestions?</p>",
      "rawMarkdown": "Has anybody any experience importing GraphNeT into Colab? It took me a few days to work out how to set everything up and I've finally got: \n\n`from graphnet.data.constants import FEATURES, TRUTH`\n\n...working. But then when I tried the following two (in both/either order):\n\n`from graphnet.models import StandardModel`\n`from graphnet.models.gnn import DynEdge`\n\n...I get \"Your session crashed for an unknown reason\" and the log doesn't appear to offer any useful information. I've already successfully run:\n\n`!pip install -r requirements/torch_gpu.txt -e .[develop,torch]`\n\n... so I assume I have the correct dependencies. I've also tried it with both GPU and CPU runtimes. Any suggestions?",
      "votes": 1
    },
    {
      "id": 2164820,
      "postDate": "2023-03-01T20:13:22.753Z",
      "rawMarkdown": "",
      "votes": -1,
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 2166673,
      "author_name": "lowerthansound",
      "author_url": "",
      "post_date": "2023-03-02T23:13:42.870000",
      "content": "<p>The notebook suddenly closing might be due to some weird version errors. In which case I'd try the following (note that I haven't tried it, so it has some - non-trivial - chance of failing):</p>\n<ul>\n<li>Restart the notebook completely (so we erase any bad imports)</li>\n<li>Make sure these are the 2 first commands that the notebook run (so put it in a cell at the top):</li>\n</ul>\n<pre><code>!pip install --force-reinstall -r /path/to/graphnet/directory/requirements/torch_cpu.txt\n!pip install /path/to/graphnet/directory\n</code></pre>\n<ul>\n<li>Test the imports:</li>\n</ul>\n<pre><code>import torch\nprint(torch.__version__)\nimport torch_geometric\nprint(torch_geometric.__version__)\nimport graphnet\nprint(graphnet.__file__)\n</code></pre>\n<p>For GPU, you might get some other problems, such as the CUDA version from graphnet not being the one installed in your environment. You can check the cuda version with <code>import torch; print(torch.cuda.version)</code> and install following instructions from the <a href=\"https://pytorch.org/get-started/previous-versions/\" target=\"_blank\">pytorch</a> and <a href=\"https://pytorch-geometric.readthedocs.io/en/2.0.4/notes/installation.html\" target=\"_blank\">pytorch-geometric</a> websites, try to match the version from the <a href=\"https://github.com/graphnet-team/graphnet/blob/main/requirements/torch_gpu.txt\" target=\"_blank\">graphnet requirements file</a> (for example, if cuda is 11.3, install torch 1.11.0 for cuda 11.3).</p>\n<p><code>--force-reinstall</code> might not be needed, I added just in case. You can add <code>--quiet</code> (after sorting all out) to silence pip.</p>\n<p>Cheers,<br>\nlts</p>\n<p>PS: It might be something related to memory too? So make sure you're not loading anything in the beginning, just get the imports right and only then start loading the files.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2167616,
          "author_name": "Michael Barrett",
          "author_url": "",
          "post_date": "2023-03-03T15:57:23.700000",
          "content": "<p>Thanks for your help.</p>\n<p>The problem related to numerous issues including (but not limited to): my lack of experience with Conda (or any other) environments and some Colab related idiosynchracies, as well as torch-geometric taking minutes to download - but then an hour to build and install.</p>\n<p>IIRC, that particular module (from graphnet.data.constants import FEATURES, TRUTH) stopped crashing when I made sure I ran this first:</p>\n<p><code>!pip install colorlog</code></p>",
          "votes": 0,
          "replies": [
            {
              "id": 2168054,
              "author_name": "lowerthansound",
              "author_url": "",
              "post_date": "2023-03-03T20:48:55.210000",
              "content": "<p>Damn, I'm always sorry for people first coming into python package issues, it's always a f*cking mess haha In any case, good to know that you had your problem sorted, good luck in the competition !</p>",
              "votes": 1,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2164820,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-03-01T20:13:22.753000",
      "content": "",
      "votes": -1,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2166673": "The notebook suddenly closing might be due to some weird version errors. In which case I'd try the following (note that I haven't tried it, so it has some - non-trivial - chance of failing):\n\n- Restart the notebook completely (so we erase any bad imports)\n- Make sure these are the 2 first commands that the notebook run (so put it in a cell at the top):\n\n```\n!pip install --force-reinstall -r /path/to/graphnet/directory/requirements/torch_cpu.txt\n!pip install /path/to/graphnet/directory\n```\n\n- Test the imports:\n\n```\nimport torch\nprint(torch.__version__)\nimport torch_geometric\nprint(torch_geometric.__version__)\nimport graphnet\nprint(graphnet.__file__)\n```\n\nFor GPU, you might get some other problems, such as the CUDA version from graphnet not being the one installed in your environment. You can check the cuda version with `import torch; print(torch.cuda.version)` and install following instructions from the [pytorch](https://pytorch.org/get-started/previous-versions/) and [pytorch-geometric](https://pytorch-geometric.readthedocs.io/en/2.0.4/notes/installation.html) websites, try to match the version from the [graphnet requirements file](https://github.com/graphnet-team/graphnet/blob/main/requirements/torch_gpu.txt) (for example, if cuda is 11.3, install torch 1.11.0 for cuda 11.3).\n\n`--force-reinstall` might not be needed, I added just in case. You can add `--quiet` (after sorting all out) to silence pip.\n\nCheers,\nlts\n\nPS: It might be something related to memory too? So make sure you're not loading anything in the beginning, just get the imports right and only then start loading the files.",
    "2164381": "Has anybody any experience importing GraphNeT into Colab? It took me a few days to work out how to set everything up and I've finally got: \n\n`from graphnet.data.constants import FEATURES, TRUTH`\n\n...working. But then when I tried the following two (in both/either order):\n\n`from graphnet.models import StandardModel`\n`from graphnet.models.gnn import DynEdge`\n\n...I get \"Your session crashed for an unknown reason\" and the log doesn't appear to offer any useful information. I've already successfully run:\n\n`!pip install -r requirements/torch_gpu.txt -e .[develop,torch]`\n\n... so I assume I have the correct dependencies. I've also tried it with both GPU and CPU runtimes. Any suggestions?",
    "2164820": ""
  }
}