Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUDA out of memory. #7

Open
Jamie-Cheung opened this issue Mar 13, 2022 · 11 comments
Open

CUDA out of memory. #7

Jamie-Cheung opened this issue Mar 13, 2022 · 11 comments

Comments

@Jamie-Cheung
Copy link

I try to train this code on 23090, but it still replys that CUDA out of memory. In your paper, you say that your model is trained on 2 Tesla V100 and 2 GeForce RTX 3090 GPUs spending about one day. I want to know whether this code can be trained on 23090. Than you for your contribution.

@diyiiyiii
Copy link
Owner

You can reduce the content size and style size in the training process. But I am not sure if it will affect the stylization effect.

@yuchen202
Copy link

can you test it now? can we communicate?

@Jamie-Cheung
Copy link
Author

can you test it now? can we communicate?

I can't test successfully and i don't know why.

@yuchen202
Copy link

can you test it now? can we communicate?

I can't test successfully and i don't know why.

my wechat is c319186779.Can we communicate more?

@55jun
Copy link

55jun commented Apr 20, 2022

Hallo, can you test successfully now? How to slove the error tuple object has no attribute cpu

@Jamie-Cheung
Copy link
Author

Hallo, can you test successfully now? How to slove the error tuple object has no attribute cpu

for content_path in content_paths:
for style_path in style_paths:
print(content_path)

    content_tf1 = content_transform()
    content = content_tf(Image.open(content_path).convert("RGB"))

    h, w, c = np.shape(content)
    style_tf1 = style_transform(h, w)
    style = style_tf(Image.open(style_path).convert("RGB"))

    style = style.to(device).unsqueeze(0)
    content = content.to(device).unsqueeze(0)

    with torch.no_grad():
        output = network(content, style)
        # output = output.cuda()
        output = output

    output_name = '{:s}/{:s}_stylized_{:s}{:s}'.format(
        output_path, splitext(basename(content_path))[0],
        splitext(basename(style_path))[0], save_ext
    )
    save_image(output[0], output_name)

You can copy this code to replace corresponding code on test.py

@phhandong
Copy link

Hallo, can you test successfully now? How to slove the error tuple object has no attribute cpu

for content_path in content_paths: for style_path in style_paths: print(content_path)

    content_tf1 = content_transform()
    content = content_tf(Image.open(content_path).convert("RGB"))

    h, w, c = np.shape(content)
    style_tf1 = style_transform(h, w)
    style = style_tf(Image.open(style_path).convert("RGB"))

    style = style.to(device).unsqueeze(0)
    content = content.to(device).unsqueeze(0)

    with torch.no_grad():
        output = network(content, style)
        # output = output.cuda()
        output = output

    output_name = '{:s}/{:s}_stylized_{:s}{:s}'.format(
        output_path, splitext(basename(content_path))[0],
        splitext(basename(style_path))[0], save_ext
    )
    save_image(output[0], output_name)

You can copy this code to replace corresponding code on test.py

Did you successfully test it?I editted the code as yours but in vain, may you share your environment?

@Shenyve0101
Copy link

Hallo, can you test successfully now? How to slove the error tuple object has no attribute cpu

for content_path in content_paths: for style_path in style_paths: print(content_path)

    content_tf1 = content_transform()
    content = content_tf(Image.open(content_path).convert("RGB"))

    h, w, c = np.shape(content)
    style_tf1 = style_transform(h, w)
    style = style_tf(Image.open(style_path).convert("RGB"))

    style = style.to(device).unsqueeze(0)
    content = content.to(device).unsqueeze(0)

    with torch.no_grad():
        output = network(content, style)
        # output = output.cuda()
        output = output

    output_name = '{:s}/{:s}_stylized_{:s}{:s}'.format(
        output_path, splitext(basename(content_path))[0],
        splitext(basename(style_path))[0], save_ext
    )
    save_image(output[0], output_name)

You can copy this code to replace corresponding code on test.py

Did you successfully test it?I editted the code as yours but in vain, may you share your environment?

Maybe you can try the following code:

        style = style.to(device).unsqueeze(0)
        content = content.to(device).unsqueeze(0)

        #with torch.no_grad():
        #    output= network(content,style)       
        #output = output.cpu()

        with torch.no_grad():
            output = network(content, style)
        output = output[0].cpu()
                
        output_name = '{:s}/{:s}_stylized_{:s}{:s}'.format(
            output_path, splitext(basename(content_path))[0],
            splitext(basename(style_path))[0], save_ext
        )
 
        save_image(output, output_name)

@phhandong
Copy link

Hallo, can you test successfully now? How to slove the error tuple object has no attribute cpu

for content_path in content_paths: for style_path in style_paths: print(content_path)

    content_tf1 = content_transform()
    content = content_tf(Image.open(content_path).convert("RGB"))

    h, w, c = np.shape(content)
    style_tf1 = style_transform(h, w)
    style = style_tf(Image.open(style_path).convert("RGB"))

    style = style.to(device).unsqueeze(0)
    content = content.to(device).unsqueeze(0)

    with torch.no_grad():
        output = network(content, style)
        # output = output.cuda()
        output = output

    output_name = '{:s}/{:s}_stylized_{:s}{:s}'.format(
        output_path, splitext(basename(content_path))[0],
        splitext(basename(style_path))[0], save_ext
    )
    save_image(output[0], output_name)

You can copy this code to replace corresponding code on test.py

Did you successfully test it?I editted the code as yours but in vain, may you share your environment?

Maybe you can try the following code:

        style = style.to(device).unsqueeze(0)
        content = content.to(device).unsqueeze(0)

        #with torch.no_grad():
        #    output= network(content,style)       
        #output = output.cpu()

        with torch.no_grad():
            output = network(content, style)
        output = output[0].cpu()
                
        output_name = '{:s}/{:s}_stylized_{:s}{:s}'.format(
            output_path, splitext(basename(content_path))[0],
            splitext(basename(style_path))[0], save_ext
        )
 
        save_image(output, output_name)

Thank u so much!It works perfectly,and I found a mistake in the version of cuda,the code can only run on the cuda 10.x or lower.

@Link-32
Copy link

Link-32 commented Apr 3, 2023

Have you solved your problem? I tried to run this code in RTX3080 with 10G memory and got "CUDA OUT OF MEMORY". I can only run this code when the batch size is 1. Once the batch size is greater than 1, even if iters is 1, it will report an error.

@yuchen202
Copy link

yuchen202 commented Apr 3, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants