Unity使用AnimeGANv3实现动漫风格化效果(二)

尝试使用GPU加速,做一下记录

放出效果图......

改了一行代码

csharp 复制代码
// 创建会话选项,可以设置使用CPU或GPU
var options = new SessionOptions();
// 如果使用GPU,可以设置ExecutionProvider为CUDA(需要安装CUDA和cuDNN,并且ONNX Runtime支持)
//options.AppendExecutionProvider_DML(0);
// 否则使用CPU
//options.AppendExecutionProvider_CPU();
options.AppendExecutionProvider_CUDA();

安装CUDA Toolkit 12.8

https://developer.nvidia.com/cuda-12-8-0-download-archive?target_os=Windows&target_arch=x86_64&target_version=11&target_type=exe_local

配置系统环境变量

安装CUDNN 9.0.0.312

https://developer.download.nvidia.cn/compute/cudnn/redist/cudnn/windows-x86_64/cudnn-windows-x86_64-9.0.0.312_cuda12-archive.zip

配置环境变量

查找依赖拷贝相关dll到Unity

查找相关依赖

csharp 复制代码
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.14.17
** Copyright (c) 2025 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files\Microsoft Visual Studio\2022\Community>dumpbin /dependents E:\MyProject\AnimeGANv3-unity\Assets\Plugins\Win\x86_64\onnxruntime.dll
Microsoft (R) COFF/PE Dumper Version 14.44.35217.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file E:\MyProject\AnimeGANv3-unity\Assets\Plugins\Win\x86_64\onnxruntime.dll

File Type: DLL

  Image has the following dependencies:

    KERNEL32.dll
    MSVCP140.dll
    VCRUNTIME140_1.dll
    VCRUNTIME140.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-filesystem-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    ADVAPI32.dll
    SETUPAPI.dll
    dxgi.dll
    api-ms-win-core-path-l1-1-0.dll
    MSVCP140_1.dll
    api-ms-win-crt-time-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
    dbghelp.dll

  Summary

       64000 .data
       4E000 .pdata
      237000 .rdata
        F000 .reloc
        1000 .rsrc
      9BE000 .text
        1000 _RDATA

C:\Program Files\Microsoft Visual Studio\2022\Community>dumpbin /dependents E:\MyProject\AnimeGANv3-unity\Assets\Plugins\Win\x86_64\onnxruntime_providers_cuda.dll
Microsoft (R) COFF/PE Dumper Version 14.44.35217.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file E:\MyProject\AnimeGANv3-unity\Assets\Plugins\Win\x86_64\onnxruntime_providers_cuda.dll

File Type: DLL

  Image has the following dependencies:

    cublasLt64_12.dll
    cublas64_12.dll
    cufft64_11.dll
    cudart64_12.dll
    onnxruntime_providers_shared.dll
    cudnn64_9.dll
    KERNEL32.dll
    MSVCP140.dll
    VCRUNTIME140.dll
    VCRUNTIME140_1.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-environment-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-filesystem-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll

  Summary

      21F000 .data
        1000 .nvFatBi
    1056B000 .nv_fatb
       60000 .pdata
     229E000 .rdata
        7000 .reloc
        1000 .rsrc
      B0F000 .text

C:\Program Files\Microsoft Visual Studio\2022\Community>dumpbin /dependents E:\MyProject\AnimeGANv3-unity\Assets\Plugins\Win\x86_64\onnxruntime_providers_shared.dll
Microsoft (R) COFF/PE Dumper Version 14.44.35217.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file E:\MyProject\AnimeGANv3-unity\Assets\Plugins\Win\x86_64\onnxruntime_providers_shared.dll

File Type: DLL

  Image has the following dependencies:

    KERNEL32.dll
    VCRUNTIME140.dll
    api-ms-win-crt-runtime-l1-1-0.dll

  Summary

        1000 .data
        1000 .pdata
        1000 .rdata
        1000 .reloc
        1000 .rsrc
        1000 .text

C:\Program Files\Microsoft Visual Studio\2022\Community>

文件过大无法上传到github

onnxruntime相关文件从nuget获取,其他依赖dll从cuda和cudnn里找

相关推荐
天人合一peng1 小时前
unity 通过代码修改button及其名字字体的属性
unity·游戏引擎
GLDbalala5 小时前
Unity基于自定义管线实现经典经验光照模型
unity·游戏引擎
心疼你的一切8 小时前
Unity异步编程神器:Unitask库深度解析(功能+实战案例+API全指南)
深度学习·unity·c#·游戏引擎·unitask
呆呆敲代码的小Y10 小时前
【Unity 实用工具篇】 | Book Page Curl 快速实现翻书效果
游戏·unity·游戏引擎·u3d·免费游戏·翻书插件
AC梦1 天前
unity中如何将UI上的字高清显示
ui·unity
小贺儿开发1 天前
Unity3D 智慧城市管理平台
数据库·人工智能·unity·智慧城市·数据可视化
June bug2 天前
【领域知识】休闲游戏一次发版全流程:Google Play + Apple App Store
unity
星夜泊客2 天前
C# 基础:为什么类可以在静态方法中创建自己的实例?
开发语言·经验分享·笔记·unity·c#·游戏引擎
dzj20212 天前
PointerEnter、PointerExit、PointerDown、PointerUp——鼠标点击物体,则开始旋转,鼠标离开或者松开物体,则停止旋转
unity·pointerdown·pointerup
心前阳光2 天前
Unity 模拟父子关系
android·unity·游戏引擎