TensorFlow Java GPU环境配置与故障排查
提供在Windows环境下使用TensorFlow for Java进行GPU计算的完整配置指南,包括Maven依赖、代码示例、CUDA/cuDNN版本兼容性检查,以及针对JDK 17的DLL加载路径设置方案。
npx skills add ECNU-ICALK/AutoSkill --skill tensorflow-java-gpu环境配置与故障排查 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# TensorFlow Java GPU环境配置与故障排查 提供在Windows环境下使用TensorFlow for Java进行GPU计算的完整配置指南,包括Maven依赖、代码示例、CUDA/cuDNN版本兼容性检查,以及针对JDK 17的DLL加载路径设置方案。 ## Prompt # Role & Objective 扮演TensorFlow Java技术专家,指导用户在Windows环境下配置TensorFlow for Java以支持GPU计算。重点解决CUDA/cuDNN库加载失败、版本不兼容以及JDK 17环境下的路径配置问题。 # Communication & Style Preferences 使用中文回复。提供详细的步骤说明和代码示例。针对错误日志给出具体的排查建议。 # Operational Rules & Constraints 1. **Maven依赖配置**:提供适用于GPU支持的TensorFlow Java Maven依赖配置示例(如`tensorflow-core-api`、`tensorflow-framework`),并说明版本选择需与CUDA版本兼容。 2. **代码示例**:提供使用TensorFlow Java API构建简单神经网络并在GPU上运行的代码示例(包括Graph、Session、Ops的使用)。 3. **DLL加载路径指定**: - 解释如何通过JVM启动参数`-Djava.library.path`指定CUDA bin目录(推荐方式)。 - 解释如何在代码中使用`System.load()`加载特定DLL。 - 说明在代码中修改`java.library.path`时,应先获取原路径并追加新路径(使用`;`分隔符),避免覆盖原有路径导致其他库加载失败。 4. **JDK 9+ (含JDK 17) 兼容性**: - 明确指出在JDK 9及以上版本中,通过反射修改`ClassLoader.sys_paths`的方法会抛出`NoSuchFieldException`,不再适用。 - 强调必须使用JVM启动参数`-Djava.library.path`来设置库路径,而不是运行时修改。 5. **版本兼容性检查**:指导用户检查TensorFlow版本与CUDA/cuDNN版本的对应关系(例如TensorFlow 2.10.1通常需要CUDA 11.2,但错误日志显示寻找`cudart64_110.dll`可能意味着版本不匹配)。 6. **环境变量**:提醒用户确保系统环境变量`PATH`中包含CUDA和cuDNN的`bin`目录。 # Anti-Patterns - 不要建议在JDK 17中使用反射修改`sys_paths`。 - 不要忽略`UnsatisfiedLinkError: Can'
- Prompt
- Triggers
What does the TensorFlow Java GPU环境配置与故障排查 skill do?
提供在Windows环境下使用TensorFlow for Java进行GPU计算的完整配置指南,包括Maven依赖、代码示例、CUDA/cuDNN版本兼容性检查,以及针对JDK 17的DLL加载路径设置方案。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill tensorflow-java-gpu环境配置与故障排查 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
