Getting a CUDA error when trying to run my notebook. I’m using Kaggle GPU for training.

Screenshot from 2021-11-04 21-45-311380×365 58.6 KB

Link to my notebook:
  

      github.com
  

  
    aleksandarilic95/Sharing-notebooks/blob/main/notebookd4fdcb1ddd.ipynb 1


    {"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.10","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nfrom matplotlib import pyplot as plt\nimport torch\nimport os\nimport cv2\n\ndef decode_rle_to_mask(rle_array, height, width, viz=False):\n    mask = np.zeros((height*width, 1))\n    if viz:\n        color = np.random.rand(3)\n    else:\n        color = [1]\n    for i in rle_array:\n        mask[int(i[0]):int(i[0])+int(i[1]), :] = color\n        \n    result = mask.reshape(height, width)\n    return result\n    \ndef create_mask(df, image_id, height, width): \n    filtered_df = df[df.id == image_id]\n    result_array = np.zeros(height * width).reshape(height, width)\n    for index, row in filtered_df.iterrows():\n        annotation_list = row[\"annotation\"].split()\n        annotation_list = map(int, annotation_list)\n        annotation_list = list(annotation_list)\n        annotation_np_array = np.array(annotation_list)\n        annotation_np_array = annotation_np_array.reshape(-1, 2)\n        annotation_np_array[:,0] -= 1\n        \n        result_array = result_array + decode_rle_to_mask(annotation_np_array, height, width)\n        \n    \n    result_array[result_array > 1] = 1    \n    return result_array\n  \ndef mask_on_image(path_to_image, image_name, height, width, df):\n    original_array = cv2.imread(os.path.join(path_to_image, image_name + '.png'))\n    result_array = create_mask(df, image_name, 520, 704)\n    plt.figure(figsize=(32,18))\n    plt.imshow(original_array, interpolation = 'none')\n    plt.imshow(result_array, interpolation='none', alpha = 0.2)\n    plt.show()\n    \ndef rle2bbox(rle, shape):\n    '''\n    rle: run-length encoded image mask, as string\n    shape: (height, width) of image on which RLE was produced\n    Returns (x0, y0, x1, y1) tuple describing the bounding box of the rle mask\n    \n    Note on image vs np.array dimensions:\n    \n        np.array implies the `[y, x]` indexing order in terms of image dimensions,\n        so the variable on `shape[0]` is `y`, and the variable on the `shape[1]` is `x`,\n        hence the result would be correct (x0,y0,x1,y1) in terms of image dimensions\n        for RLE-encoded indices of np.array (which are produced by widely used kernels\n        and are used in most kaggle competitions datasets)\n    '''\n    \n    a = np.fromiter(rle.split(), dtype=np.uint)\n    a = a.reshape((-1, 2))  # an array of (start, length) pairs\n    a[:,0] -= 1  # `start` is 1-indexed\n    \n    x0 = a[:,0] % shape[1]\n    x1 = x0 + a[:,1]\n    if np.any(x1 > shape[1]):\n        # got `y` overrun, meaning that there are a pixels in mask on 0 and shape[0] position\n        x0 = 0\n        x1 = shape[1]\n    else:\n        x0 = np.min(x0)\n        x1 = np.max(x1)\n    \n    y0 = a[:,0] // shape[1]\n    y1 = (a[:,0] + a[:,1]) // shape[1]\n    y0 = np.min(y0)\n    y1 = np.max(y1)\n    \n    if x1 > shape[1]:\n        # just went out of the image dimensions\n        raise ValueError(\"invalid RLE or image dimensions: x1=%d > shape[1]=%d\" % (\n            x1, shape[1]\n        ))\n\n    return x0, y0, x1, y1\n    \ndef create_bbox_list_by_image(df, image_id):\n    filtered_df = df[df.id == image_id]\n    return_list = []\n    for index, row in filtered_df.iterrows():\n        annotation_list = row[\"annotation\"]\n        height, width = row[\"height\"], row[\"width\"]\n        \n        return_list.append(rle2bbox(annotation_list, (height, width)))\n        \n    return return_list\n\ndef update_dataset_with_bbox(df):\n    df[\"bbox\"] = \"empty\"\n    for index, row in df.iterrows():\n        sample_annot = row[\"annotation\"]\n        height, width = row[\"height\"], row[\"width\"]\n        x0, y0, x1, y1 = rle2bbox(sample_annot, (height, width))\n        df[\"bbox\"][index] = f\"{x0} {y0} {x1} {y1}\"\n        \n    return df\n  \ndef my_collate(batch):\n    return tuple(zip(*batch))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-11-04T21:39:49.266460Z","iopub.execute_input":"2021-11-04T21:39:49.266736Z","iopub.status.idle":"2021-11-04T21:39:49.470609Z","shell.execute_reply.started":"2021-11-04T21:39:49.266698Z","shell.execute_reply":"2021-11-04T21:39:49.469884Z"},"trusted":true},"execution_count":2,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport torch\nfrom torch.utils.data import Dataset, DataLoader\nimport torchvision\nfrom torchvision.models.detection.faster_rcnn import FastRCNNPredictor\nfrom torchvision.models.detection.mask_rcnn import MaskRCNNPredictor\nfrom PIL import Image\nimport os\n\nfrom tqdm.notebook import t


  This file has been truncated. show original

  

  
    
    
  

  


If you need any more info I’ll provide it, just not sure what info should I provide.