Graphormer部署教程:Nginx反向代理+Basic Auth实现安全内网访问
Graphormer部署教程Nginx反向代理Basic Auth实现安全内网访问1. 项目概述Graphormer是一种基于纯Transformer架构的图神经网络专门为分子图原子-键结构的全局结构建模与属性预测而设计。该模型在OGB、PCQM4M等分子基准测试中表现优异大幅超越了传统GNN模型。核心特性模型名称microsoft/Graphormer (Distributional-Graphormer)版本property-guided checkpoint模型大小3.7GB部署日期2026-03-272. 环境准备2.1 系统要求Linux服务器推荐Ubuntu 20.04Nginx 1.18Python 3.11推荐使用miniconda管理环境至少8GB可用显存推荐RTX 4090 24GB2.2 安装依赖# 安装Nginx sudo apt update sudo apt install -y nginx apache2-utils # 创建Python环境 conda create -n graphormer python3.11 conda activate graphormer # 安装模型依赖 pip install rdkit-pypi torch-geometric ogb gradio6.10.0 torch2.8.03. 基础部署3.1 下载模型mkdir -p /root/ai-models/microsoft/Graphormer/ # 假设模型文件已放置在指定目录3.2 启动服务# 使用Supervisor管理服务 sudo apt install -y supervisor创建Supervisor配置文件/etc/supervisor/conf.d/graphormer.conf[program:graphormer] command/root/miniconda3/envs/graphormer/bin/python /root/graphormer/app.py directory/root/graphormer userroot autostarttrue autorestarttrue stderr_logfile/root/logs/graphormer.log stdout_logfile/root/logs/graphormer.log4. Nginx安全配置4.1 设置Basic Auth# 创建认证文件 sudo htpasswd -c /etc/nginx/.htpasswd graphormer_user4.2 Nginx反向代理配置创建/etc/nginx/sites-available/graphormerserver { listen 80; server_name your_domain_or_ip; location / { auth_basic Restricted Access; auth_basic_user_file /etc/nginx/.htpasswd; proxy_pass http://localhost:7860; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }启用配置sudo ln -s /etc/nginx/sites-available/graphormer /etc/nginx/sites-enabled sudo nginx -t sudo systemctl restart nginx5. 服务管理5.1 常用命令# 查看服务状态 supervisorctl status graphormer # 启动/停止/重启服务 supervisorctl start graphormer supervisorctl stop graphormer supervisorctl restart graphormer # 查看日志 tail -f /root/logs/graphormer.log5.2 防火墙设置# 开放80端口 sudo ufw allow 80/tcp sudo ufw enable6. 使用指南6.1 访问服务通过浏览器访问http://your_server_ip6.2 输入分子SMILES在Web界面中输入分子SMILES格式例如乙醇CCO苯c1ccccc1乙酸CC(O)O6.3 选择预测任务property-guided: 分子属性预测catalyst-adsorption: 催化剂吸附预测7. 常见问题解决7.1 服务状态显示STARTING模型首次加载需要时间约3-5分钟等待状态变为RUNNING即可。7.2 端口访问问题检查步骤确认Nginx服务运行正常systemctl status nginx检查防火墙设置sudo ufw status验证端口监听netstat -tulnp | grep 807.3 认证失败确保.htpasswd文件权限正确644用户名密码输入正确Nginx配置中指定了正确的.htpasswd路径8. 总结通过本教程您已经完成了Graphormer模型的基础部署Nginx反向代理配置Basic Auth安全认证设置服务管理和常见问题解决这种部署方式特别适合需要内网安全访问的科研场景既保证了服务的可用性又通过基础认证防止未授权访问。获取更多AI镜像想探索更多AI镜像和应用场景访问 CSDN星图镜像广场提供丰富的预置镜像覆盖大模型推理、图像生成、视频生成、模型微调等多个领域支持一键部署。