CuPy running out of memory
I have been testing the CuPy library and done a simple matrix multiplication using einsum:
C = cp.einsum('pqrs,rs->pq', A, B)
Dimensions of A and B are, (41, 41, 41, 41) (41, 41), receptively. I also checked their sizes, which are 22606088 bytes, 13448 bytes.
While running the code, I am getting the following error message:
OutOfMemoryError: out of memory to allocate 38000834048 bytes (total 38023468032 bytes)
It indicates that I am running out of memory. Is there any option to sent data partially to the device and perform operations in terms of batches?
python chainer cupy
add a comment |
I have been testing the CuPy library and done a simple matrix multiplication using einsum:
C = cp.einsum('pqrs,rs->pq', A, B)
Dimensions of A and B are, (41, 41, 41, 41) (41, 41), receptively. I also checked their sizes, which are 22606088 bytes, 13448 bytes.
While running the code, I am getting the following error message:
OutOfMemoryError: out of memory to allocate 38000834048 bytes (total 38023468032 bytes)
It indicates that I am running out of memory. Is there any option to sent data partially to the device and perform operations in terms of batches?
python chainer cupy
2
What CuPy version are you using? Could you add the output ofcupy.show_config()
?
– Kenichi Maehashi
Nov 16 at 3:39
add a comment |
I have been testing the CuPy library and done a simple matrix multiplication using einsum:
C = cp.einsum('pqrs,rs->pq', A, B)
Dimensions of A and B are, (41, 41, 41, 41) (41, 41), receptively. I also checked their sizes, which are 22606088 bytes, 13448 bytes.
While running the code, I am getting the following error message:
OutOfMemoryError: out of memory to allocate 38000834048 bytes (total 38023468032 bytes)
It indicates that I am running out of memory. Is there any option to sent data partially to the device and perform operations in terms of batches?
python chainer cupy
I have been testing the CuPy library and done a simple matrix multiplication using einsum:
C = cp.einsum('pqrs,rs->pq', A, B)
Dimensions of A and B are, (41, 41, 41, 41) (41, 41), receptively. I also checked their sizes, which are 22606088 bytes, 13448 bytes.
While running the code, I am getting the following error message:
OutOfMemoryError: out of memory to allocate 38000834048 bytes (total 38023468032 bytes)
It indicates that I am running out of memory. Is there any option to sent data partially to the device and perform operations in terms of batches?
python chainer cupy
python chainer cupy
edited Nov 16 at 5:21
talonmies
59.1k17128196
59.1k17128196
asked Nov 16 at 2:27
EveSz
162
162
2
What CuPy version are you using? Could you add the output ofcupy.show_config()
?
– Kenichi Maehashi
Nov 16 at 3:39
add a comment |
2
What CuPy version are you using? Could you add the output ofcupy.show_config()
?
– Kenichi Maehashi
Nov 16 at 3:39
2
2
What CuPy version are you using? Could you add the output of
cupy.show_config()
?– Kenichi Maehashi
Nov 16 at 3:39
What CuPy version are you using? Could you add the output of
cupy.show_config()
?– Kenichi Maehashi
Nov 16 at 3:39
add a comment |
1 Answer
1
active
oldest
votes
I think there is no option to send data partially for one-array.
And I faced same issue before, this may be caused because the cupy einsum efficiency is not optimized yet.
https://github.com/cupy/cupy/issues/19#issuecomment-322972682
If you can try replacing your einsum function by using transpose
, reshape
and matmul
etc, please try those.
I guess
C = cp.einsum('pqrs,rs->pq', A, B)
is equivalent to
p, q, r, s = A.shape
A = cp.reshape(A, (p, q, r*s))
B = cp.reshape(B, (1, 1, r*s))
C = cp.sum(A * B, axis=2)
You are right, this way works. It looks the CuPy einsum is not optimized. I also noticed that this library does not work if the available memory is excited, what is a huge drawback. Well, we know that GPU cards do not provide to much memory. Have you tried to go around it?
– EveSz
Nov 17 at 16:03
1
I thinkeinsum
implementation is updated, I don't know which cupy version you are using but latest version may work more efficiently.
– corochann
Nov 18 at 13:21
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330588%2fcupy-running-out-of-memory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think there is no option to send data partially for one-array.
And I faced same issue before, this may be caused because the cupy einsum efficiency is not optimized yet.
https://github.com/cupy/cupy/issues/19#issuecomment-322972682
If you can try replacing your einsum function by using transpose
, reshape
and matmul
etc, please try those.
I guess
C = cp.einsum('pqrs,rs->pq', A, B)
is equivalent to
p, q, r, s = A.shape
A = cp.reshape(A, (p, q, r*s))
B = cp.reshape(B, (1, 1, r*s))
C = cp.sum(A * B, axis=2)
You are right, this way works. It looks the CuPy einsum is not optimized. I also noticed that this library does not work if the available memory is excited, what is a huge drawback. Well, we know that GPU cards do not provide to much memory. Have you tried to go around it?
– EveSz
Nov 17 at 16:03
1
I thinkeinsum
implementation is updated, I don't know which cupy version you are using but latest version may work more efficiently.
– corochann
Nov 18 at 13:21
add a comment |
I think there is no option to send data partially for one-array.
And I faced same issue before, this may be caused because the cupy einsum efficiency is not optimized yet.
https://github.com/cupy/cupy/issues/19#issuecomment-322972682
If you can try replacing your einsum function by using transpose
, reshape
and matmul
etc, please try those.
I guess
C = cp.einsum('pqrs,rs->pq', A, B)
is equivalent to
p, q, r, s = A.shape
A = cp.reshape(A, (p, q, r*s))
B = cp.reshape(B, (1, 1, r*s))
C = cp.sum(A * B, axis=2)
You are right, this way works. It looks the CuPy einsum is not optimized. I also noticed that this library does not work if the available memory is excited, what is a huge drawback. Well, we know that GPU cards do not provide to much memory. Have you tried to go around it?
– EveSz
Nov 17 at 16:03
1
I thinkeinsum
implementation is updated, I don't know which cupy version you are using but latest version may work more efficiently.
– corochann
Nov 18 at 13:21
add a comment |
I think there is no option to send data partially for one-array.
And I faced same issue before, this may be caused because the cupy einsum efficiency is not optimized yet.
https://github.com/cupy/cupy/issues/19#issuecomment-322972682
If you can try replacing your einsum function by using transpose
, reshape
and matmul
etc, please try those.
I guess
C = cp.einsum('pqrs,rs->pq', A, B)
is equivalent to
p, q, r, s = A.shape
A = cp.reshape(A, (p, q, r*s))
B = cp.reshape(B, (1, 1, r*s))
C = cp.sum(A * B, axis=2)
I think there is no option to send data partially for one-array.
And I faced same issue before, this may be caused because the cupy einsum efficiency is not optimized yet.
https://github.com/cupy/cupy/issues/19#issuecomment-322972682
If you can try replacing your einsum function by using transpose
, reshape
and matmul
etc, please try those.
I guess
C = cp.einsum('pqrs,rs->pq', A, B)
is equivalent to
p, q, r, s = A.shape
A = cp.reshape(A, (p, q, r*s))
B = cp.reshape(B, (1, 1, r*s))
C = cp.sum(A * B, axis=2)
answered Nov 16 at 2:58
corochann
1,0701618
1,0701618
You are right, this way works. It looks the CuPy einsum is not optimized. I also noticed that this library does not work if the available memory is excited, what is a huge drawback. Well, we know that GPU cards do not provide to much memory. Have you tried to go around it?
– EveSz
Nov 17 at 16:03
1
I thinkeinsum
implementation is updated, I don't know which cupy version you are using but latest version may work more efficiently.
– corochann
Nov 18 at 13:21
add a comment |
You are right, this way works. It looks the CuPy einsum is not optimized. I also noticed that this library does not work if the available memory is excited, what is a huge drawback. Well, we know that GPU cards do not provide to much memory. Have you tried to go around it?
– EveSz
Nov 17 at 16:03
1
I thinkeinsum
implementation is updated, I don't know which cupy version you are using but latest version may work more efficiently.
– corochann
Nov 18 at 13:21
You are right, this way works. It looks the CuPy einsum is not optimized. I also noticed that this library does not work if the available memory is excited, what is a huge drawback. Well, we know that GPU cards do not provide to much memory. Have you tried to go around it?
– EveSz
Nov 17 at 16:03
You are right, this way works. It looks the CuPy einsum is not optimized. I also noticed that this library does not work if the available memory is excited, what is a huge drawback. Well, we know that GPU cards do not provide to much memory. Have you tried to go around it?
– EveSz
Nov 17 at 16:03
1
1
I think
einsum
implementation is updated, I don't know which cupy version you are using but latest version may work more efficiently.– corochann
Nov 18 at 13:21
I think
einsum
implementation is updated, I don't know which cupy version you are using but latest version may work more efficiently.– corochann
Nov 18 at 13:21
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330588%2fcupy-running-out-of-memory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
What CuPy version are you using? Could you add the output of
cupy.show_config()
?– Kenichi Maehashi
Nov 16 at 3:39