0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Google Colaboratoryをイジメるよ

0
Posted at

目的

Google Colaboratoryのメモリ上限を探る

コード

import time
import numpy as np
from itertools import product
import sys

now = time.time()

for l in [101,1001,11001]:
  a = np.linspace(0,1,l)
  b = np.linspace(1,2,l)
  c = np.array(list(product(a,b)))
  elapsed_time = time.time() - now
  print(f"経過時間:{elapsed_time}")
  print("MB:",sys.getsizeof(c)/1000000)

実行結果

経過時間:0.07169699668884277
MB: 0.163328
経過時間:0.6292345523834229
MB: 16.032128
経過時間:65.04300308227539
MB: 1936.352128

考察

2GB越えるとダメっぽい

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?