Closed zsy0828 closed 1 week ago
您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档、常见问题、历史Issue、AI社区来寻求解答。祝您生活愉快~
Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the API,FAQ,Github Issue and AI community to get the answer.Have a nice day!
您好,正在询问相关开发接口人员中,请您稍等。
`import os os.environ['CUDA_VISIBLE_DEVICES'] = '1'
import cupy as cp from paddle.utils.dlpack import from_dlpack import paddle
def test1():
for i in range(1000):
a = paddle.rand((1000000, 602), dtype=cp.float32)
print(a.place)
def test2(): with cp.cuda.Device(0):
for i in range(100):
a = cp.random.random((1000000, 602), dtype=cp.float32)
# a = from_dlpack(a.toDlpack())
b = paddle.Tensor(a)
print(b.place)
del b
test2()` test code
请提出你的问题 Please ask your question
当使用cupy和paddle相结合是,在每个batch中,我都会将cupy的数据通过from_dlpack(a.toDlpack())转换,其中a是cupy.ndarray。 但是这样做会导致内存直接占用爆炸,即在batch结束后,不会自动的删除未使用的部分(我认为是这样的),请问,如何避免出现这种情况,谢谢. 注:pytorch和tensorflow均不会出现这样的情况