Skip to content

Instantly share code, notes, and snippets.

@kmaehashi
Created June 6, 2017 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmaehashi/ef5931ab758db1fdaa08474596eec5ec to your computer and use it in GitHub Desktop.
Save kmaehashi/ef5931ab758db1fdaa08474596eec5ec to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import cupy
import threading
import random
import sys
# enable memory pool
cupy.cuda.memory.set_allocator(cupy.cuda.memory.MemoryPool().malloc)
def run():
cupy.cuda.runtime.free(0)
while True:
print(".")
x = cupy.arange(int(2000000 * random.random()))
for i in range(10):
x = x - 1
threads = []
for x in range(2):
threads.append(threading.Thread(target=run))
for t in threads: t.setDaemon(True)
for t in threads: t.start()
for t in threads: t.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment