{
  "id": 208110,
  "title": "[Updated]cannot load local model into notebook(GCP downloading issue)",
  "url": "/competitions/riiid-test-answer-prediction/discussion/208110",
  "author_name": "LeoF",
  "post_date": "2021-01-02T00:57:04.991000",
  "votes": 2,
  "comment_count": 25,
  "views": 0,
  "content": "<p>I uploaded a local lgbm model as my dataset and added it into my kernel. But the kernel automatically restarted when I tried to load this model. Everything goes well when I use kernel output model. </p>\n<p>Anyone can help? Thanks!</p>\n<hr>\n<p>Updated. I found a stupid way to deal with downloading issue.</p>\n<p><strong>Issue</strong>: The size of file I want to download is 1.2+GB, but I can only download up to 200MB from GCP JupyterLab. So, it kills kernel at loading an incomplete file. So, let's reduce the file size.<br>\n<strong>Solution</strong>: Compress the file using <strong>bz2</strong>. It compressed my 1.2+GB file to only 15MB file (amazing!). Then we can successfully download it. The code is as following:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984447%2F31c6d0a6c7cf9668416c9f6676c7a58a%2Fgcpissue.jpg?generation=1609561873225491&amp;alt=media\" alt=\"\"></p>\n<p>It would be better if I can find a way to connect kaggle dataset with GCP JupyterLab output.</p>\n<hr>\n<blockquote>\n  <p>It would be better if I can find a way to connect kaggle dataset with GCP JupyterLab output.</p>\n</blockquote>\n<p>Update a <a href=\"https://www.kaggle.com/woshifym/upload-gcp-jupyterlab-data-to-kaggle-dataset?scriptVersionId=52904076\" target=\"_blank\">notebook</a></p>",
  "messages": [
    {
      "id": 1135182,
      "postDate": "2021-01-02T00:57:04.990Z",
      "content": "<p>I uploaded a local lgbm model as my dataset and added it into my kernel. But the kernel automatically restarted when I tried to load this model. Everything goes well when I use kernel output model. </p>\n<p>Anyone can help? Thanks!</p>\n<hr>\n<p>Updated. I found a stupid way to deal with downloading issue.</p>\n<p><strong>Issue</strong>: The size of file I want to download is 1.2+GB, but I can only download up to 200MB from GCP JupyterLab. So, it kills kernel at loading an incomplete file. So, let's reduce the file size.<br>\n<strong>Solution</strong>: Compress the file using <strong>bz2</strong>. It compressed my 1.2+GB file to only 15MB file (amazing!). Then we can successfully download it. The code is as following:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984447%2F31c6d0a6c7cf9668416c9f6676c7a58a%2Fgcpissue.jpg?generation=1609561873225491&amp;alt=media\" alt=\"\"></p>\n<p>It would be better if I can find a way to connect kaggle dataset with GCP JupyterLab output.</p>\n<hr>\n<blockquote>\n  <p>It would be better if I can find a way to connect kaggle dataset with GCP JupyterLab output.</p>\n</blockquote>\n<p>Update a <a href=\"https://www.kaggle.com/woshifym/upload-gcp-jupyterlab-data-to-kaggle-dataset?scriptVersionId=52904076\" target=\"_blank\">notebook</a></p>",
      "rawMarkdown": "I uploaded a local lgbm model as my dataset and added it into my kernel. But the kernel automatically restarted when I tried to load this model. Everything goes well when I use kernel output model. \n\nAnyone can help? Thanks!\n\n--------------------------------------------------------------\nUpdated. I found a stupid way to deal with downloading issue.\n\n**Issue**: The size of file I want to download is 1.2+GB, but I can only download up to 200MB from GCP JupyterLab. So, it kills kernel at loading an incomplete file. So, let's reduce the file size.\n**Solution**: Compress the file using **bz2**. It compressed my 1.2+GB file to only 15MB file (amazing!). Then we can successfully download it. The code is as following:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984447%2F31c6d0a6c7cf9668416c9f6676c7a58a%2Fgcpissue.jpg?generation=1609561873225491&alt=media)\n\nIt would be better if I can find a way to connect kaggle dataset with GCP JupyterLab output.\n\n--------------------------------------------------------------\n> It would be better if I can find a way to connect kaggle dataset with GCP JupyterLab output.\n\nUpdate a [notebook](https://www.kaggle.com/woshifym/upload-gcp-jupyterlab-data-to-kaggle-dataset?scriptVersionId=52904076)\n",
      "votes": 2
    },
    {
      "id": 1135208,
      "postDate": "2021-01-02T02:42:17.087Z",
      "content": "<p>I have the exact same problem, apparently the model files are downloaded/uploaded incomplete and truncated. The problem here is not the way you save or load the model, I tried model.save_model(), pickle and joblib and the problem persists. Something wrong happens when you download the model to your local machine or upload the model to kaggle.<br>\nAre you using jupyterLab for training and you download the output from there?</p>",
      "rawMarkdown": "I have the exact same problem, apparently the model files are downloaded/uploaded incomplete and truncated. The problem here is not the way you save or load the model, I tried model.save_model(), pickle and joblib and the problem persists. Something wrong happens when you download the model to your local machine or upload the model to kaggle.\nAre you using jupyterLab for training and you download the output from there?",
      "votes": 1,
      "replies": [
        {
          "id": 1135210,
          "postDate": "2021-01-02T02:47:23.107Z",
          "content": "<p>I had this problem too, it was my connection apparently, during the download of the model, it failed midway and it got truncated.</p>",
          "rawMarkdown": "I had this problem too, it was my connection apparently, during the download of the model, it failed midway and it got truncated.",
          "votes": 1
        },
        {
          "id": 1135213,
          "postDate": "2021-01-02T02:55:36.900Z",
          "content": "<p><a href=\"https://www.kaggle.com/abdessalemboukil\" target=\"_blank\">@abdessalemboukil</a> How did you solve the problem? By changing your internet connection? :)</p>",
          "rawMarkdown": "@abdessalemboukil How did you solve the problem? By changing your internet connection? :)"
        },
        {
          "id": 1135216,
          "postDate": "2021-01-02T03:12:18.097Z",
          "content": "<p>I used GCP AI platform. Cannot download a complete model. How can I fix it?</p>",
          "rawMarkdown": "I used GCP AI platform. Cannot download a complete model. How can I fix it?"
        },
        {
          "id": 1135217,
          "postDate": "2021-01-02T03:20:10.337Z",
          "content": "<p>Same, I am using GCP. In the <a href=\"https://cloud.google.com/ai-platform/notebooks/docs/troubleshooting\" target=\"_blank\">AI notebook troubleshooting section</a> they are mentioning some failed download problems, not the same as our case, but they suggest downgrading your notebook package:</p>\n<pre><code>sudo pip3 install notebook==5.7.5\nsudo service jupyter restart\n</code></pre>\n<p>I haven't tried it yet, if it works for you, please let me know.</p>",
          "rawMarkdown": "Same, I am using GCP. In the [AI notebook troubleshooting section](https://cloud.google.com/ai-platform/notebooks/docs/troubleshooting) they are mentioning some failed download problems, not the same as our case, but they suggest downgrading your notebook package:\n```\nsudo pip3 install notebook==5.7.5\nsudo service jupyter restart\n```\nI haven't tried it yet, if it works for you, please let me know."
        },
        {
          "id": 1135223,
          "postDate": "2021-01-02T03:32:47.320Z",
          "content": "<p>For now, I can only download up to at most 200MB file from GCP notebook, but the size of my model is 1.2GB. It is really stupid. Do you know how to move the file to google cloud or bucket using notebook?</p>",
          "rawMarkdown": "For now, I can only download up to at most 200MB file from GCP notebook, but the size of my model is 1.2GB. It is really stupid. Do you know how to move the file to google cloud or bucket using notebook?"
        },
        {
          "id": 1135234,
          "postDate": "2021-01-02T03:54:08.060Z",
          "content": "<p>I am uploading model file in GCP VM instance using kaggle datasets command. This is the fastest :)</p>",
          "rawMarkdown": "I am uploading model file in GCP VM instance using kaggle datasets command. This is the fastest :)\n",
          "votes": 1
        },
        {
          "id": 1135237,
          "postDate": "2021-01-02T03:56:28.603Z",
          "content": "<p>Assume you have already dataset created.</p>\n<ol>\n<li>download metadata for the dataset <code>kaggle datasets metadata -p . higepon/your_dataset_name</code></li>\n<li>Upload <code>kaggle datasets version -p . -m \"Updates my    model files\"</code></li>\n</ol>",
          "rawMarkdown": "Assume you have already dataset created.\n1. download metadata for the dataset ```kaggle datasets metadata -p . higepon/your_dataset_name```\n2. Upload ```kaggle datasets version -p . -m \"Updates my    model files\"```",
          "votes": 2
        },
        {
          "id": 1135536,
          "postDate": "2021-01-02T10:25:15.683Z",
          "content": "<p><a href=\"https://www.kaggle.com/higepon\" target=\"_blank\">@higepon</a> do you store your files in a GS bucket or you run the command and upload directly from the notebook?</p>",
          "rawMarkdown": "@higepon do you store your files in a GS bucket or you run the command and upload directly from the notebook?"
        },
        {
          "id": 1135541,
          "postDate": "2021-01-02T10:31:14.080Z",
          "content": "<p>I did it from my notebook.</p>",
          "rawMarkdown": "I did it from my notebook."
        },
        {
          "id": 1135648,
          "postDate": "2021-01-02T11:58:32.180Z",
          "content": "<p>Thanks <a href=\"https://www.kaggle.com/higepon\" target=\"_blank\">@higepon</a>! I am getting an error while trying to add the metadata file to the created dataset<br>\n <code>!kaggle datasets metadata -p . amiiiney/riid-model</code>. Any idea how to solve it?</p>",
          "rawMarkdown": "Thanks @higepon! I am getting an error while trying to add the metadata file to the created dataset\n ```!kaggle datasets metadata -p . amiiiney/riid-model```. Any idea how to solve it?\n"
        },
        {
          "id": 1135685,
          "postDate": "2021-01-02T12:38:31.627Z",
          "content": "<p>Sure. Could I have error details here? thanks!</p>",
          "rawMarkdown": "Sure. Could I have error details here? thanks!",
          "votes": 1
        },
        {
          "id": 1135691,
          "postDate": "2021-01-02T12:40:40.940Z",
          "content": "<p>Please note that you have to create your API credential and store it in GCP.<br>\n<a href=\"https://github.com/Kaggle/kaggle-api#api-credentials\" target=\"_blank\">https://github.com/Kaggle/kaggle-api#api-credentials</a></p>",
          "rawMarkdown": "Please note that you have to create your API credential and store it in GCP.\nhttps://github.com/Kaggle/kaggle-api#api-credentials",
          "votes": 1
        },
        {
          "id": 1135709,
          "postDate": "2021-01-02T12:46:54.140Z",
          "content": "<p>I am using my API token that I download from my account</p>\n<pre><code>!mkdir ~/.kaggle\n!cp /home/kaggle.json ~/.kaggle/kaggle.json\n</code></pre>\n<p>And then I create the metadata file and edit it with my dataset's name </p>\n<pre><code>!kaggle datasets init -p /home/\n!kaggle datasets create -p /home/\n</code></pre>\n<p>And I get this error when I add the metadata<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3451735%2Fe6f77bc458db25d58c2da3c7c616af90%2FScreen%20Shot%202021-01-02%20at%2013.42.53.png?generation=1609591587042259&amp;alt=media\" alt=\"\"></p>",
          "rawMarkdown": "I am using my API token that I download from my account\n```\n!mkdir ~/.kaggle\n!cp /home/kaggle.json ~/.kaggle/kaggle.json\n```\nAnd then I create the metadata file and edit it with my dataset's name \n```\n!kaggle datasets init -p /home/\n!kaggle datasets create -p /home/\n```\nAnd I get this error when I add the metadata\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3451735%2Fe6f77bc458db25d58c2da3c7c616af90%2FScreen%20Shot%202021-01-02%20at%2013.42.53.png?generation=1609591587042259&alt=media)\n",
          "votes": 1
        },
        {
          "id": 1135728,
          "postDate": "2021-01-02T13:04:50.257Z",
          "content": "<p>You may want to install another version of kaggle API. See <a href=\"https://github.com/Kaggle/kaggle-api/issues/235\" target=\"_blank\">issue</a> here.</p>\n<p>FIY I tried on my GCP as follows and it worked as expected.<br>\n-<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2199749%2F95757ed4199de862f36b2ff7e2d86ed8%2F2021-01-02%2022.02.18.png?generation=1609592567487223&amp;alt=media\" alt=\"\"><br>\n-<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2199749%2Facb304afc751880c5339600a86701ae2%2F2021-01-02%2022.02.24.png?generation=1609592585507290&amp;alt=media\" alt=\"\"></p>",
          "rawMarkdown": "You may want to install another version of kaggle API. See [issue](https://github.com/Kaggle/kaggle-api/issues/235) here.\n\nFIY I tried on my GCP as follows and it worked as expected.\n-![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2199749%2F95757ed4199de862f36b2ff7e2d86ed8%2F2021-01-02%2022.02.18.png?generation=1609592567487223&alt=media)\n-![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2199749%2Facb304afc751880c5339600a86701ae2%2F2021-01-02%2022.02.24.png?generation=1609592585507290&alt=media)",
          "votes": 1
        },
        {
          "id": 1135753,
          "postDate": "2021-01-02T13:21:01.883Z",
          "content": "<p>Thanks a lot <a href=\"https://www.kaggle.com/higepon\" target=\"_blank\">@higepon</a> :) It finally worked with kaggle version 1.5.4!</p>",
          "rawMarkdown": "Thanks a lot @higepon :) It finally worked with kaggle version 1.5.4!",
          "votes": 1
        }
      ]
    },
    {
      "id": 1135227,
      "postDate": "2021-01-02T03:42:19.123Z",
      "content": "<p>I suggest trying to load a model locally first see if it works.</p>",
      "rawMarkdown": "I suggest trying to load a model locally first see if it works.",
      "replies": [
        {
          "id": 1135232,
          "postDate": "2021-01-02T03:48:25.763Z",
          "content": "<p>Yes. I have found the problem that I cannot download a complete file from GCP JupyterLab. So, I was loading the incomplete file, which was killing the kernel. Have totally no idea how to fix it.</p>",
          "rawMarkdown": "Yes. I have found the problem that I cannot download a complete file from GCP JupyterLab. So, I was loading the incomplete file, which was killing the kernel. Have totally no idea how to fix it."
        }
      ]
    },
    {
      "id": 1135184,
      "postDate": "2021-01-02T01:02:22.870Z",
      "content": "<p>How do you save and load model?</p>",
      "rawMarkdown": "How do you save and load model?",
      "replies": [
        {
          "id": 1135186,
          "postDate": "2021-01-02T01:04:39.647Z",
          "content": "<p>I use joblib and it works for me</p>\n<p>import joblib<br>\njoblib.dump(my_model, 'lgb.pkl')<br>\nmodel = joblib.load('lgb.pkl')</p>",
          "rawMarkdown": "I use joblib and it works for me\n\nimport joblib\njoblib.dump(my_model, 'lgb.pkl')\nmodel = joblib.load('lgb.pkl')"
        },
        {
          "id": 1135192,
          "postDate": "2021-01-02T01:25:49.797Z",
          "content": "<p>Thanks <a href=\"https://www.kaggle.com/fredegrec\" target=\"_blank\">@fredegrec</a> <br>\nI used model.save_model() and lgb.Booster(model_file='…'). I will try your method later. I checked my model.txt,and it seems the file is not completed. Maybe there was something wrong during saving the model. </p>\n<p>Can I directly use model.predict after <code>model = joblib.load('lgb.pkl')</code> in your method?</p>",
          "rawMarkdown": "Thanks @fredegrec \nI used model.save_model() and lgb.Booster(model_file='...'). I will try your method later. I checked my model.txt,and it seems the file is not completed. Maybe there was something wrong during saving the model. \n\nCan I directly use model.predict after `model = joblib.load('lgb.pkl')` in your method?"
        },
        {
          "id": 1135195,
          "postDate": "2021-01-02T01:36:20.583Z",
          "content": "<p>I'm using <code>model.model_to_string()</code> to get model as string and save it with <code>joblib.dump</code>.<br>\nThen upload the .joblib file to my private dataset, load the .joblib using <code>joblib.load</code>and <code>lgb.Booster(model_str=model_str)</code> to load the model for submission.</p>\n<p>Hope it helps.</p>",
          "rawMarkdown": "I'm using ```model.model_to_string()``` to get model as string and save it with ```joblib.dump```.\nThen upload the .joblib file to my private dataset, load the .joblib using ```joblib.load```and ```lgb.Booster(model_str=model_str)``` to load the model for submission.\n\nHope it helps.",
          "votes": 2
        },
        {
          "id": 1135201,
          "postDate": "2021-01-02T01:48:33.880Z",
          "content": "<p><a href=\"https://www.kaggle.com/woshifym\" target=\"_blank\">@woshifym</a> Yes, you can</p>",
          "rawMarkdown": "@woshifym Yes, you can"
        },
        {
          "id": 1135202,
          "postDate": "2021-01-02T02:03:39.143Z",
          "content": "<p>Will try, thanks.</p>",
          "rawMarkdown": "Will try, thanks."
        }
      ]
    },
    {
      "id": 1135252,
      "postDate": "2021-01-02T04:38:17.460Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 1135208,
      "author_name": "Amin",
      "author_url": "",
      "post_date": "2021-01-02T02:42:17.087000",
      "content": "<p>I have the exact same problem, apparently the model files are downloaded/uploaded incomplete and truncated. The problem here is not the way you save or load the model, I tried model.save_model(), pickle and joblib and the problem persists. Something wrong happens when you download the model to your local machine or upload the model to kaggle.<br>\nAre you using jupyterLab for training and you download the output from there?</p>",
      "votes": 1,
      "replies": [
        {
          "id": 1135210,
          "author_name": "Abdessalem Boukil",
          "author_url": "",
          "post_date": "2021-01-02T02:47:23.107000",
          "content": "<p>I had this problem too, it was my connection apparently, during the download of the model, it failed midway and it got truncated.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1135213,
          "author_name": "Amin",
          "author_url": "",
          "post_date": "2021-01-02T02:55:36.900000",
          "content": "<p><a href=\"https://www.kaggle.com/abdessalemboukil\" target=\"_blank\">@abdessalemboukil</a> How did you solve the problem? By changing your internet connection? :)</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135216,
          "author_name": "LeoF",
          "author_url": "",
          "post_date": "2021-01-02T03:12:18.097000",
          "content": "<p>I used GCP AI platform. Cannot download a complete model. How can I fix it?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135217,
          "author_name": "Amin",
          "author_url": "",
          "post_date": "2021-01-02T03:20:10.337000",
          "content": "<p>Same, I am using GCP. In the <a href=\"https://cloud.google.com/ai-platform/notebooks/docs/troubleshooting\" target=\"_blank\">AI notebook troubleshooting section</a> they are mentioning some failed download problems, not the same as our case, but they suggest downgrading your notebook package:</p>\n<pre><code>sudo pip3 install notebook==5.7.5\nsudo service jupyter restart\n</code></pre>\n<p>I haven't tried it yet, if it works for you, please let me know.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135223,
          "author_name": "LeoF",
          "author_url": "",
          "post_date": "2021-01-02T03:32:47.320000",
          "content": "<p>For now, I can only download up to at most 200MB file from GCP notebook, but the size of my model is 1.2GB. It is really stupid. Do you know how to move the file to google cloud or bucket using notebook?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135234,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2021-01-02T03:54:08.060000",
          "content": "<p>I am uploading model file in GCP VM instance using kaggle datasets command. This is the fastest :)</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1135237,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2021-01-02T03:56:28.603000",
          "content": "<p>Assume you have already dataset created.</p>\n<ol>\n<li>download metadata for the dataset <code>kaggle datasets metadata -p . higepon/your_dataset_name</code></li>\n<li>Upload <code>kaggle datasets version -p . -m \"Updates my    model files\"</code></li>\n</ol>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 1135536,
          "author_name": "Amin",
          "author_url": "",
          "post_date": "2021-01-02T10:25:15.683000",
          "content": "<p><a href=\"https://www.kaggle.com/higepon\" target=\"_blank\">@higepon</a> do you store your files in a GS bucket or you run the command and upload directly from the notebook?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135541,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2021-01-02T10:31:14.080000",
          "content": "<p>I did it from my notebook.</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135648,
          "author_name": "Amin",
          "author_url": "",
          "post_date": "2021-01-02T11:58:32.180000",
          "content": "<p>Thanks <a href=\"https://www.kaggle.com/higepon\" target=\"_blank\">@higepon</a>! I am getting an error while trying to add the metadata file to the created dataset<br>\n <code>!kaggle datasets metadata -p . amiiiney/riid-model</code>. Any idea how to solve it?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135685,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2021-01-02T12:38:31.627000",
          "content": "<p>Sure. Could I have error details here? thanks!</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1135691,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2021-01-02T12:40:40.940000",
          "content": "<p>Please note that you have to create your API credential and store it in GCP.<br>\n<a href=\"https://github.com/Kaggle/kaggle-api#api-credentials\" target=\"_blank\">https://github.com/Kaggle/kaggle-api#api-credentials</a></p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1135709,
          "author_name": "Amin",
          "author_url": "",
          "post_date": "2021-01-02T12:46:54.140000",
          "content": "<p>I am using my API token that I download from my account</p>\n<pre><code>!mkdir ~/.kaggle\n!cp /home/kaggle.json ~/.kaggle/kaggle.json\n</code></pre>\n<p>And then I create the metadata file and edit it with my dataset's name </p>\n<pre><code>!kaggle datasets init -p /home/\n!kaggle datasets create -p /home/\n</code></pre>\n<p>And I get this error when I add the metadata<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F3451735%2Fe6f77bc458db25d58c2da3c7c616af90%2FScreen%20Shot%202021-01-02%20at%2013.42.53.png?generation=1609591587042259&amp;alt=media\" alt=\"\"></p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1135728,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2021-01-02T13:04:50.257000",
          "content": "<p>You may want to install another version of kaggle API. See <a href=\"https://github.com/Kaggle/kaggle-api/issues/235\" target=\"_blank\">issue</a> here.</p>\n<p>FIY I tried on my GCP as follows and it worked as expected.<br>\n-<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2199749%2F95757ed4199de862f36b2ff7e2d86ed8%2F2021-01-02%2022.02.18.png?generation=1609592567487223&amp;alt=media\" alt=\"\"><br>\n-<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F2199749%2Facb304afc751880c5339600a86701ae2%2F2021-01-02%2022.02.24.png?generation=1609592585507290&amp;alt=media\" alt=\"\"></p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1135753,
          "author_name": "Amin",
          "author_url": "",
          "post_date": "2021-01-02T13:21:01.883000",
          "content": "<p>Thanks a lot <a href=\"https://www.kaggle.com/higepon\" target=\"_blank\">@higepon</a> :) It finally worked with kaggle version 1.5.4!</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1135227,
      "author_name": "Shuhao Cao",
      "author_url": "",
      "post_date": "2021-01-02T03:42:19.123000",
      "content": "<p>I suggest trying to load a model locally first see if it works.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 1135232,
          "author_name": "LeoF",
          "author_url": "",
          "post_date": "2021-01-02T03:48:25.763000",
          "content": "<p>Yes. I have found the problem that I cannot download a complete file from GCP JupyterLab. So, I was loading the incomplete file, which was killing the kernel. Have totally no idea how to fix it.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1135184,
      "author_name": "Alyona Pasevieva",
      "author_url": "",
      "post_date": "2021-01-02T01:02:22.870000",
      "content": "<p>How do you save and load model?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 1135186,
          "author_name": "Alyona Pasevieva",
          "author_url": "",
          "post_date": "2021-01-02T01:04:39.647000",
          "content": "<p>I use joblib and it works for me</p>\n<p>import joblib<br>\njoblib.dump(my_model, 'lgb.pkl')<br>\nmodel = joblib.load('lgb.pkl')</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135192,
          "author_name": "LeoF",
          "author_url": "",
          "post_date": "2021-01-02T01:25:49.797000",
          "content": "<p>Thanks <a href=\"https://www.kaggle.com/fredegrec\" target=\"_blank\">@fredegrec</a> <br>\nI used model.save_model() and lgb.Booster(model_file='…'). I will try your method later. I checked my model.txt,and it seems the file is not completed. Maybe there was something wrong during saving the model. </p>\n<p>Can I directly use model.predict after <code>model = joblib.load('lgb.pkl')</code> in your method?</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135195,
          "author_name": "higepon",
          "author_url": "",
          "post_date": "2021-01-02T01:36:20.583000",
          "content": "<p>I'm using <code>model.model_to_string()</code> to get model as string and save it with <code>joblib.dump</code>.<br>\nThen upload the .joblib file to my private dataset, load the .joblib using <code>joblib.load</code>and <code>lgb.Booster(model_str=model_str)</code> to load the model for submission.</p>\n<p>Hope it helps.</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 1135201,
          "author_name": "Alyona Pasevieva",
          "author_url": "",
          "post_date": "2021-01-02T01:48:33.880000",
          "content": "<p><a href=\"https://www.kaggle.com/woshifym\" target=\"_blank\">@woshifym</a> Yes, you can</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 1135202,
          "author_name": "LeoF",
          "author_url": "",
          "post_date": "2021-01-02T02:03:39.143000",
          "content": "<p>Will try, thanks.</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1135252,
      "author_name": "",
      "author_url": "",
      "post_date": "2021-01-02T04:38:17.460000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1135182": "I uploaded a local lgbm model as my dataset and added it into my kernel. But the kernel automatically restarted when I tried to load this model. Everything goes well when I use kernel output model. \n\nAnyone can help? Thanks!\n\n--------------------------------------------------------------\nUpdated. I found a stupid way to deal with downloading issue.\n\n**Issue**: The size of file I want to download is 1.2+GB, but I can only download up to 200MB from GCP JupyterLab. So, it kills kernel at loading an incomplete file. So, let's reduce the file size.\n**Solution**: Compress the file using **bz2**. It compressed my 1.2+GB file to only 15MB file (amazing!). Then we can successfully download it. The code is as following:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1984447%2F31c6d0a6c7cf9668416c9f6676c7a58a%2Fgcpissue.jpg?generation=1609561873225491&alt=media)\n\nIt would be better if I can find a way to connect kaggle dataset with GCP JupyterLab output.\n\n--------------------------------------------------------------\n> It would be better if I can find a way to connect kaggle dataset with GCP JupyterLab output.\n\nUpdate a [notebook](https://www.kaggle.com/woshifym/upload-gcp-jupyterlab-data-to-kaggle-dataset?scriptVersionId=52904076)\n",
    "1135208": "I have the exact same problem, apparently the model files are downloaded/uploaded incomplete and truncated. The problem here is not the way you save or load the model, I tried model.save_model(), pickle and joblib and the problem persists. Something wrong happens when you download the model to your local machine or upload the model to kaggle.\nAre you using jupyterLab for training and you download the output from there?",
    "1135227": "I suggest trying to load a model locally first see if it works.",
    "1135184": "How do you save and load model?",
    "1135252": ""
  }
}