Viscosity is an essential transport property in gas dynamics, especially the bulk viscosity which performs of quite more complexity. Carbon monoxide (CO) is molecule of weak polarity, which exists in many important field of combustion and coke metallurgy etc. In order to effectively uncover the mechanism of the CO viscosity, this study dealt with it from a microscopic view. A transcale model was built which integrates density functional theory (DFT, first-principles) calculations with equilibrium molecular dynamics (EMD) simulations to establish the microscale foundation. Based on that, a fitted high-precision potential function was formed, then by using the Green-Kubo linear response theory, the shear and bulk viscosities of CO were achieved over a medium temperature range of 100-800 K. The MD simulation was implemented with C programming language, and an adaptive time-step algorithm was applied that significantly enhanced the computational efficiency. The resulted bulk viscosity exhibits quite obvious sensitivity to the potential function of the molecule system, while the shear viscosity shows little. Comparing to the shear viscosity appearing more of linearity, the bulk viscosity demonstrates certain clear nonlinearity changing with temperature, see Fig. Ab1. Correspondingly, traditional theoretic models and experimental results from different literature showed to overestimate the bulk viscosity to different extent at medium temperatures. Fitting functions on the shear and bulk viscosities in the defined temperature range were established, respectively. Additionally, lower system pressure and larger system size with the model turned out to both effectively reduce statistical pressure difference fluctuations and improve the convergence in related laws, respectively. This work elucidates the microscopic mechanism of CO viscosity and further provides a high-fidelity theoretical tool for modeling viscosity of high-temperature nonequilibrium gas flows (e.g., hypersonic boundary layers, plasma transport, etc.).