最近研究圖神經網路的一篇論文

2019 Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks

論文實現需要使用graph clustering 的工具 Metis 除此之外 還需要python的warper

在安裝的過程中花了很多時間採坑,中間看到有個pymetis的套件看起來安裝好像比較簡單,但是遇到一堆問題

最後還是按照paper的做法安裝metis 與python warpper,因為平常受益於許多先進在知乎上的文章,所以也把我的採坑心得分享給大家

最後安裝成功流程主要參考Stackflow的一篇文章How to install METIS package in python on windows?

另外如果是用官方metis 在VS編譯上遇到問題,可以參考下面這篇,或許有辦法解決迦非喵:网格剖分软件Metis5.1.0不同系统下的编译问题​zhuanlan.zhihu.com

因為是從.md匯入的,如果排版跑掉造成閱讀不順暢還請見諒

Envirement

OS: Win10 x64

Python 3.7

Requirement

這裡我選擇安裝 Cmake 3.16 與 Visual Studio 2019(x64)

順便一提,會選擇這樣的版本是因為使用 Cmake 建立 metis 的時候,Cmake 2.8 只支援到 Visual Studio 2013

相信只要抓相容的Visual Studio,Cmake 2.8 也是可以的

Visual Studio 安裝的時候記得勾選 "使用C++的桌面開發"(desktop application development using c++)

Download metis and unzip

你可以在這裡下載官方Metis 但是根據參考文章的步驟,我最後安裝成功的是conda-metis 下載完畢後解壓縮

Metis document

將Metis 打開以後,你可以在裡面看到三個安裝文檔: "install.txt" , "Build.txt" , "Build-Windows.txt"

但是只按照上面的步驟,我怎麼樣都安裝不成功...,所以還是參考ref.中的步驟吧

Install.txt

These are some preliminary instructions for the 5.0 release of METIS.You need to have a C compiler that supports the C99 standard. Gcc works just fine, but I have not tested it on many other architectures (any feedback/patches for different architectures are welcomed)

You need to have GNU make and CMake 2.8 (http://www.cmake.org/) installed.

Edit the file include/metis.h and specify the width (32 or 64 bits) of the elementary data type used in METIS. This is controled by the IDXTYPEWIDTH constant.

For now, on a 32 bit architecture you can only specify a width of 32, whereas for a 64 bit architecture you can specify a width of either 32 or 64 bits.At the top of Metis' directory execute 'make' and follow the instructions.

make

To build on windows using Visual Studio follow the instructions in the file BUILD-Windows.txt.

Build-Windows.txt

Building METIS requires CMake 2.8, found at http://www.cmake.org/. CMake generates Visual Studio project files, which then can be built using Visual Studio. There are two ways to generate visual studio files: using the command line and using the CMake GUI.

Using the command line

Open the command prompt and cd to the METIS source directory. Run

> cmake --help

and look at the list of generators for the Visual Studio studio you want to build for. For example, the generator for Visual Studio 2010 is called "Visual Studio 10".

After you have found the appropriate generator, run

> .\vsgen -G ""

to generate the project files. The project files will be placed build\windows.

Using the CMake GUI

It is also possible to use the CMake GUI, distributed with CMake. To do this, open the CMake GUI, and browse to the location of METIS' source with the "Browse Source" button. You can also change the binary directory. This is where the Visual Studio project files will be placed. Click "Generate" to select the correct visual studio version and build the project files.

Using the VS project files

The Visual Studio project will be called METIS.sln. Open it in Visual Studio. If the configuration is not already "Release", set it to "Release". Type F7 to build. The METIS library will be in \libmetis\Release and the executable programs will be in \programs\Release. ( will be build\windows if you used the command line or whatever you choose if using the CMake GUI.)

安裝步驟Install Step:

設定環境變數:(使用管理員權限執行以下command)

VS 2017

set VCTargetPaths=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets

VS 2019

set VCTargetPaths=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160

順帶一提,我當初忘記使用最高權限開啟command line。= =....

所以這個步驟或許不影響

2. 修改註冊表:

打開你的註冊表(regedit)

找到Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\

我們要修改兩個變數(variable) 1) .\4.0\ 中的變數MSBuildOverrideTasksPath 2) .\ToolVersion\4.0\ 中的變數 MSBuildToolPath 將兩個變數修改為: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin

如果是VS 2017,就將路徑中的2019改為2017

3. 修改CMakeList.txt:

對於 python metis ,我們需要.dll 檔而非 .lib檔案

編輯C:\\conda-metis\CMakeLists.txt

在第19行(line 19)加入 set(METIS_LIBRARY_TYPE SHARED)

4.修改 metis.h (option):

編輯 C:\\conda-metis\include\metis.h

將變數 IDXTYPEWIDTH 從 32改為64

注意只有x64的系統才可以修改,x86不行

5. 確認Cmake相容性:

開啟 command line,並到conda-metis路徑中

run: cmake--help

這時候會跑出一堆generator 的list,如 "Visual Studio 16 2019"

如果沒有,就代表你的Cmake 版本跟 VS 不匹配,要再去找相容的版本

6.在conda-metis的路徑中

run: .\vsgen -G "Visual Studio 16 2019" -A x64

如果是安裝 x86的VS,指令改為 .\vsgen -G "Visual Studio 16 2019"

如果執行正常的話,資料夾 conda-metis\build\windows\ 裡面應該就有許多檔案 (如 METIS.sln 等)

7.修改gk_arch.h : (在VS build metis時的rint()問題,詳情請見連結)

編輯 C:\\conda-metis\GKlib\gk_arch.h

找到 #define rint(x) ((idx_t)((x)+0.5)) 並刪除

8.建立資料庫檔案:

用Viusal Studio 打開 C:\\conda-metis\build\windows\METIS.sln

打開時我的方案組態(configuration) 已經是Release

在上方指令選擇 "建置(B)" (Build) => "為解決方案建置完整程式資料庫" (Build Solusion)

9.設定METIS_DLL環境變數:

如果Step8正常執行,metis.dll檔案會在

C:\\conda-metis\build\windows\libmetis\Release\

run: set METIS_DLL=C:\\conda-metis\build\windows\libmetis\Release\metis.dll

10.安裝 metis python warpper:metis(0.2a4):

in command line

run: pip install metis

以上是參考文章都有提及的東西,但是你還可能會遇到兩個問題:

1)如果你有執行Step 4.的話,在使用python metis 的時候會遇到error:Out of Memory的問題

2)如果你是用python package: networkx 2.4 的Graph當作input,你會遇到error: 'Graph' object has no attribute 'node'

11. 編輯metis.py:

我在Anaconda上使用深度學習,metis.py 會在

C:\Users\\Anaconda3\envs\\Lib\site-packages\metis.py

問題1)

option 1 :設定環境變數 run: set METIS_IDXTYPEWIDTH = 64

option 2.:edit line 131 at metis.py:

IDXTYPEWIDTH = os.getenv('METIS_IDXTYPEWIDTH', '64')

問題2) 在metis.py 中搜尋 ".node"

將所有 H.node 修改為 H.nodes,總共有三個需要修改

測試

import metis

from networkx import karate_club_graph

zkc = karate_club_graph()

graph_clustering=metis.part_graph(zkc)

如果沒遇到問題,恭喜你完成安裝啦!!!

windows 安装metis_Metis 5.1.0 安裝心得 in Win10相关推荐

  1. linux 安装java se,Linux 下安裝 Java SE Development Kit(JDK)並配置環境變量

    終端輸入以下命令: # 創建 JDK 目錄,-p 為創建多個目錄 $ sudo mkdir -p /opt/java # 將 JDK 解壓到指定目錄(看自己的習慣) $ sudo tar zxvf ~ ...

  2. linux程序打包安装,制作Linux下程序安裝包——使用腳本打包bin、run等安裝包

    制作簡單的安裝包的時候可以簡單的用cat命令連接兩個文件,然后頭部是腳本文件,執行的時候把下面的文件分解出來就行了.一般這個后部分的文件是個壓縮包,那樣,就能夠打包很多文件了,在腳本中解壓出來即可.這 ...

  3. (轉貼) 如何解決MegaCore IP 6.0安裝時-6001的錯誤? (IC Design) (MegaCore)

    Abstract安裝MegaCore IP 6.0時,在某些電腦會出現-6001的錯誤而無法安裝,Altera原廠提出解決方法. Solution 轉貼自http://www.altera.com/s ...

  4. windows安装稳定版MySql-8.0.19.msi详细步骤(附安装包mysql+workbench)

    在文章末尾获取安装包 在文章末尾获取安装包 在文章末尾获取安装包 安装完成后就会有mysql和workbench 1.双击 mysql-installer-community-8.0.19.0.msi ...

  5. eyeOS 2.0安裝指南 - 中文版 (附英文版)zt

    如果你想没有任何缺陷或错误的安装eyeos 2.0,请按照本指南,你将会有一个全面的正确步骤,通过这种简单,快速,简便的方式进行设置,并在5分钟内可运行. 需求 Apache: ? Version 2 ...

  6. windows安装mosquito(2.0.8)

    下载地址mqtt选择2.0.8版本 安装成功修改配置文件 在1.x版本中,默认是可以匿名访问的,到了2.x版本,须自定义配置(false为需要密码登录) allow_anonymous false c ...

  7. archlinux安裝手记(Win10+Arch、GPT+UEFI、lvm)

    目录 准备工作 工具和必要技能 分区和挂载 分区建立和格式化 分区挂载 基础安装 配置镜像源 连接网络 安装基础系统 建立fstab文件 进入系统 激活lvm2钩子 用户管理 设置时区 主机名 网络配 ...

  8. windows 安装metis_图划分软件Metis的使用(win10+vs2017)

    Metis是由Karypis Lab开发的一个具有强大功能的图划分软件包,可用于划分不规则图(graph).网格(mesh)以及计算稀疏矩阵(Sparse Matrices)的Fill-Reducin ...

  9. cygwin 安装php posix,解决cygwin安装包apt-cyg 在win10下无权限的问题

    apt-cyg是cygwin的安装包管理工具,有效解决了cygwin官方setup操作繁琐的缺陷. win10下安装cygwin操作 wget https://raw.githubuserconten ...

最新文章

  1. 【转】expect语言学习笔记
  2. HDU_oj_2021 发工资喽
  3. walletconnect
  4. boost::hana::count_if用法的测试程序
  5. POJ 327820493083
  6. wince编译时找不到atls.lib
  7. 没有bug队——加贝——Python 练习实例 13,14
  8. 【OSGI】Error osgi xx Invalid value for DynamicImport-Package dynamic.import.pack
  9. C++库介绍-标准库、类库
  10. 武汉知名 IT 公司大盘点
  11. GD32F4(2): 用keil5打开官方评估版demo,编译报错找不到core_cm4.h文件
  12. C#渐变色方法 实例
  13. Python计算温度植被干旱指数(TVDI)
  14. 【C语言】求Sn=a+aa+aaa+aaaa+aaaaa的前5项之和,其中a是一个数字
  15. java树结构stream工具类
  16. PCA(非常详细)【机器学习】
  17. Python数据攻略-Pandas进行Excel文件读写
  18. [Ionic]如何实现一个全局的浮动菜单栏?
  19. 数组some和every的区别
  20. DRMsoft.cn未注册版 解决办法

热门文章

  1. 第三届“SLAM技术及应用”暑期学校日程安排
  2. python里的π怎么输入_【后端开辟】python里的π怎样输入
  3. mib2c : You didn‘t give mib2c a valid OID to start with.解决
  4. 交换机的三种端口类型
  5. IDEA 注释模板,这样配置才够逼格!
  6. 获取referer中的请求参数_javaweb之request获取referer请求头实现防盗链
  7. 微信小程序布局 头尾固定中间自适应
  8. 把object强制转换成int
  9. dbeaver的安装和使用
  10. 【概率DP】SRM515 NewItemShop